Skip to content

Commit 203af1e

Browse files
author
Abel Milash
committed
Add edge case tests for batch failure propagation and missing AttributeType
1 parent 821d4a0 commit 203af1e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/unit/data/test_odata_internal.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,18 @@ def test_check_uses_crm_in_function_in_url(self):
647647
self.assertIn('"name"', call_url)
648648
self.assertIn('"industrycode"', call_url)
649649

650+
def test_check_missing_attribute_type_cached_as_non_picklist(self):
651+
"""Attribute with missing AttributeType in response is cached as non-picklist."""
652+
mock_resp = MagicMock()
653+
mock_resp.json.return_value = {"value": [{"LogicalName": "customfield"}]} # no AttributeType key
654+
self.od._request.return_value = mock_resp
655+
656+
self.od._check_attribute_types("account", ["customfield"])
657+
658+
entry = self.od._picklist_label_cache.get(("account", "customfield"))
659+
self.assertIsNotNone(entry)
660+
self.assertEqual(entry["map"], {})
661+
650662
# ---- _optionset_map ----
651663

652664
def test_optionset_returns_none_for_empty_table(self):
@@ -1099,6 +1111,15 @@ def test_convert_partial_cache_only_batches_uncached(self):
10991111
# 1 batch (only industrycode) + 1 optionset fetch
11001112
self.assertEqual(self.od._request.call_count, 2)
11011113

1114+
def test_convert_batch_failure_propagates(self):
1115+
"""Server error during batch type-check propagates to caller."""
1116+
from PowerPlatform.Dataverse.core.errors import HttpError
1117+
1118+
self.od._request.side_effect = HttpError("Server Error", status_code=500)
1119+
1120+
with self.assertRaises(HttpError):
1121+
self.od._convert_labels_to_ints("account", {"name": "Contoso"})
1122+
11021123
def test_convert_single_picklist_makes_two_api_calls(self):
11031124
"""Single picklist field (cold cache): 1 batch + 1 optionset = 2 total."""
11041125
batch_resp = MagicMock()

0 commit comments

Comments
 (0)