Skip to content

Commit 7244b06

Browse files
committed
fix unit test after moving to CreateEntitiesAPI
1 parent fc83332 commit 7244b06

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/PowerPlatform/Dataverse/data/_odata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ def _attribute_payload(
16301630
}
16311631
if dtype_l in ("float", "double"):
16321632
return {
1633-
"@odata.type": "Microsoft.Dynamics.CRM.DoubleAttributeMetadata",
1633+
"@odata.type": "Microsoft.Dynamics.CRM.ComplexDoubleAttributeMetadata",
16341634
"SchemaName": column_schema_name,
16351635
"DisplayName": self._label(label),
16361636
"RequiredLevel": {"Value": "None"},

tests/unit/data/test_odata_internal.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ def setUp(self):
15161516
def test_int_dtype(self):
15171517
"""'int' produces IntegerAttributeMetadata."""
15181518
result = self.od._attribute_payload("new_Count", "int")
1519-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.IntegerAttributeMetadata")
1519+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexIntegerAttributeMetadata")
15201520

15211521
def test_integer_dtype_alias(self):
15221522
"""'integer' is an alias for 'int'."""
@@ -1526,7 +1526,7 @@ def test_integer_dtype_alias(self):
15261526
def test_decimal_dtype(self):
15271527
"""'decimal' produces DecimalAttributeMetadata."""
15281528
result = self.od._attribute_payload("new_Price", "decimal")
1529-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.DecimalAttributeMetadata")
1529+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexDecimalAttributeMetadata")
15301530

15311531
def test_money_dtype_alias(self):
15321532
"""'money' is an alias for 'decimal'."""
@@ -1536,7 +1536,7 @@ def test_money_dtype_alias(self):
15361536
def test_float_dtype(self):
15371537
"""'float' produces DoubleAttributeMetadata."""
15381538
result = self.od._attribute_payload("new_Score", "float")
1539-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.DoubleAttributeMetadata")
1539+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexDoubleAttributeMetadata")
15401540

15411541
def test_double_dtype_alias(self):
15421542
"""'double' is an alias for 'float'."""
@@ -1546,7 +1546,7 @@ def test_double_dtype_alias(self):
15461546
def test_datetime_dtype(self):
15471547
"""'datetime' produces DateTimeAttributeMetadata."""
15481548
result = self.od._attribute_payload("new_CreatedDate", "datetime")
1549-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.DateTimeAttributeMetadata")
1549+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexDateTimeAttributeMetadata")
15501550

15511551
def test_date_dtype_alias(self):
15521552
"""'date' is an alias for 'datetime'."""
@@ -1556,7 +1556,7 @@ def test_date_dtype_alias(self):
15561556
def test_bool_dtype(self):
15571557
"""'bool' produces BooleanAttributeMetadata."""
15581558
result = self.od._attribute_payload("new_IsActive", "bool")
1559-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.BooleanAttributeMetadata")
1559+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexBooleanAttributeMetadata")
15601560

15611561
def test_boolean_dtype_alias(self):
15621562
"""'boolean' is an alias for 'bool'."""
@@ -1566,7 +1566,7 @@ def test_boolean_dtype_alias(self):
15661566
def test_file_dtype(self):
15671567
"""'file' produces FileAttributeMetadata."""
15681568
result = self.od._attribute_payload("new_Attachment", "file")
1569-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.FileAttributeMetadata")
1569+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexFileAttributeMetadata")
15701570

15711571
def test_non_string_dtype_raises_value_error(self):
15721572
"""Non-string dtype raises ValueError."""
@@ -1576,7 +1576,7 @@ def test_non_string_dtype_raises_value_error(self):
15761576
def test_memo_type(self):
15771577
"""'memo' produces MemoAttributeMetadata with MaxLength 4000."""
15781578
result = self.od._attribute_payload("new_Notes", "memo")
1579-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.MemoAttributeMetadata")
1579+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexMemoAttributeMetadata")
15801580
self.assertEqual(result["SchemaName"], "new_Notes")
15811581
self.assertEqual(result["MaxLength"], 4000)
15821582
self.assertEqual(result["FormatName"], {"Value": "Text"})
@@ -1591,7 +1591,7 @@ def test_multiline_alias(self):
15911591
def test_string_type_max_length(self):
15921592
"""'string' produces StringAttributeMetadata with MaxLength 200."""
15931593
result = self.od._attribute_payload("new_Title", "string")
1594-
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.StringAttributeMetadata")
1594+
self.assertEqual(result["@odata.type"], "Microsoft.Dynamics.CRM.ComplexStringAttributeMetadata")
15951595
self.assertEqual(result["MaxLength"], 200)
15961596
self.assertEqual(result["FormatName"], {"Value": "Text"})
15971597

@@ -1819,7 +1819,7 @@ def test_primary_column_schema_name_used_when_provided(self):
18191819
self._setup_for_create()
18201820
self.od._create_table("new_TestTable", {}, primary_column_schema_name="new_CustomName")
18211821
post_json = self.od._request.call_args.kwargs["json"]
1822-
attrs = post_json["Attributes"]
1822+
attrs = post_json["Entities"][0]["Attributes"]
18231823
primary_attr = next((a for a in attrs if a.get("IsPrimaryName")), None)
18241824
self.assertIsNotNone(primary_attr)
18251825
self.assertEqual(primary_attr["SchemaName"], "new_CustomName")
@@ -1829,15 +1829,15 @@ def test_display_name_used_in_payload_when_provided(self):
18291829
self._setup_for_create()
18301830
self.od._create_table("new_TestTable", {}, display_name="My Test Table")
18311831
post_json = self.od._request.call_args.kwargs["json"]
1832-
label_value = post_json["DisplayName"]["LocalizedLabels"][0]["Label"]
1832+
label_value = post_json["Entities"][0]["DisplayName"]["LocalizedLabels"][0]["Label"]
18331833
self.assertEqual(label_value, "My Test Table")
18341834

18351835
def test_display_name_defaults_to_schema_name(self):
18361836
"""_create_table defaults DisplayName to table_schema_name when display_name is omitted."""
18371837
self._setup_for_create()
18381838
self.od._create_table("new_TestTable", {})
18391839
post_json = self.od._request.call_args.kwargs["json"]
1840-
label_value = post_json["DisplayName"]["LocalizedLabels"][0]["Label"]
1840+
label_value = post_json["Entities"][0]["DisplayName"]["LocalizedLabels"][0]["Label"]
18411841
self.assertEqual(label_value, "new_TestTable")
18421842

18431843
def test_display_name_empty_string_raises(self):

0 commit comments

Comments
 (0)