@@ -643,8 +643,12 @@ def test_single_failure_makes_has_errors_true(self):
643643 self .assertTrue (result .has_errors )
644644 self .assertEqual (len (result .failed ), 1 )
645645
646- def test_created_ids_from_create_multiple_response_body (self ):
647- """CreateMultiple returns IDs in data['Ids'], not in entity_id header."""
646+ def test_created_ids_from_create_multiple_not_in_created_ids (self ):
647+ """CreateMultiple IDs are in data['Ids'], NOT in created_ids property.
648+
649+ created_ids only returns entity_id from OData-EntityId headers.
650+ Callers access CreateMultiple IDs via response.data['Ids'] directly.
651+ """
648652 responses = [
649653 # CreateMultiple response: 200 OK with {"Ids": [...]} body
650654 BatchItemResponse (
@@ -654,44 +658,46 @@ def test_created_ids_from_create_multiple_response_body(self):
654658 ),
655659 ]
656660 result = BatchResult (responses = responses )
657- self .assertEqual (result .created_ids , ["guid-1" , "guid-2" , "guid-3" ])
661+ # created_ids does NOT include bulk IDs (no OData-EntityId header)
662+ self .assertEqual (result .created_ids , [])
663+ # Callers access them from the response data
664+ self .assertEqual (result .succeeded [0 ].data ["Ids" ], ["guid-1" , "guid-2" , "guid-3" ])
658665
659- def test_created_ids_combines_header_and_body_ids (self ):
660- """created_ids includes both OData-EntityId (single create) and Ids array (bulk) ."""
666+ def test_created_ids_only_from_odata_entity_id_header (self ):
667+ """created_ids only collects entity_id from OData-EntityId headers ."""
661668 responses = [
662669 # Single create: entity_id from header
663670 BatchItemResponse (status_code = 204 , entity_id = "single-id" ),
664- # CreateMultiple: Ids from body
671+ # CreateMultiple: Ids from body (not in created_ids)
665672 BatchItemResponse (
666673 status_code = 200 ,
667674 entity_id = None ,
668675 data = {"Ids" : ["bulk-id-1" , "bulk-id-2" ]},
669676 ),
670677 ]
671678 result = BatchResult (responses = responses )
672- self .assertEqual (result .created_ids , ["single-id" , "bulk-id-1" , "bulk-id-2" ])
679+ # Only the header-based entity_id
680+ self .assertEqual (result .created_ids , ["single-id" ])
681+ # Bulk IDs accessed via response.data
682+ self .assertEqual (result .responses [1 ].data ["Ids" ], ["bulk-id-1" , "bulk-id-2" ])
673683
674- def test_created_ids_ignores_non_string_ids_in_body (self ):
675- """Non-string values in data['Ids'] are filtered out ."""
684+ def test_bulk_ids_accessible_via_response_data (self ):
685+ """Callers iterate responses to access CreateMultiple/UpsertMultiple IDs ."""
676686 responses = [
687+ BatchItemResponse (status_code = 204 , entity_id = "id-1" ),
677688 BatchItemResponse (
678689 status_code = 200 ,
679- data = {"Ids" : ["good-id" , 12345 , None , "another-id" ]},
680- ),
681- ]
682- result = BatchResult (responses = responses )
683- self .assertEqual (result .created_ids , ["good-id" , "another-id" ])
684-
685- def test_created_ids_skips_failed_create_multiple (self ):
686- """Failed CreateMultiple responses should not contribute IDs."""
687- responses = [
688- BatchItemResponse (
689- status_code = 400 ,
690- data = {"error" : {"code" : "0x123" , "message" : "fail" }},
690+ data = {"Ids" : ["id-2" , "id-3" ]},
691691 ),
692+ BatchItemResponse (status_code = 204 ), # delete, no entity_id
692693 ]
693694 result = BatchResult (responses = responses )
694- self .assertEqual (result .created_ids , [])
695+ # Collect all IDs from both sources (what a caller would do)
696+ all_ids = list (result .created_ids )
697+ for resp in result .succeeded :
698+ if resp .data and isinstance (resp .data .get ("Ids" ), list ):
699+ all_ids .extend (resp .data ["Ids" ])
700+ self .assertEqual (all_ids , ["id-1" , "id-2" , "id-3" ])
695701
696702
697703# ---------------------------------------------------------------------------
@@ -733,8 +739,11 @@ def test_create_multiple_response_parsed(self):
733739 self .assertIsNone (result .succeeded [0 ].entity_id )
734740 # But data should contain the Ids array
735741 self .assertEqual (result .succeeded [0 ].data ["Ids" ], ["aaa-111" , "bbb-222" , "ccc-333" ])
736- # And created_ids should extract them
737- self .assertEqual (result .created_ids , ["aaa-111" , "bbb-222" , "ccc-333" ])
742+ # created_ids won't have these (no OData-EntityId header)
743+ self .assertEqual (result .created_ids , [])
744+ # Callers access bulk IDs via response.data["Ids"]
745+ bulk_ids = result .succeeded [0 ].data ["Ids" ]
746+ self .assertEqual (len (bulk_ids ), 3 )
738747
739748 def test_mixed_single_and_bulk_creates (self ):
740749 """Batch with both individual POST create and CreateMultiple."""
@@ -775,8 +784,10 @@ def test_mixed_single_and_bulk_creates(self):
775784
776785 self .assertFalse (result .has_errors )
777786 self .assertEqual (len (result .succeeded ), 2 )
778- # All 3 IDs should appear in created_ids
779- self .assertEqual (result .created_ids , [single_guid , "bulk-1" , "bulk-2" ])
787+ # created_ids only has the individual create's entity_id
788+ self .assertEqual (result .created_ids , [single_guid ])
789+ # CreateMultiple IDs are in the second response's data
790+ self .assertEqual (result .responses [1 ].data ["Ids" ], ["bulk-1" , "bulk-2" ])
780791
781792
782793# ---------------------------------------------------------------------------
0 commit comments