@@ -234,12 +234,9 @@ def patch_datetime_now():
234234@pytest .fixture
235235def bulk_dataframe ():
236236 return pd .DataFrame (
237- {
238- "item_id" : [f"test-{ i } " for i in range (10 )],
239- "some_property" : [f"value-{ i } " for i in range (10 )],
240- },
241- index = [i for i in range (10 )],
242- )
237+ {"some_property" : [f"value-{ i } " for i in range (10 )]},
238+ index = [f"test-{ i } " for i in range (10 )]
239+ ).rename_axis ("item_id" )
243240
244241
245242class TestSTACAPIJobDatabase :
@@ -363,14 +360,25 @@ def handle_row(series):
363360
364361 mock_requests_post .assert_called_once ()
365362
366- mock_requests_post .assert_called_with (
367- url = f"http://fake-stac-api/collections/{ job_db_exists .collection_id } /bulk_items" ,
368- auth = None ,
369- json = {
370- "method" : "upsert" ,
371- "items" : {item .id : item .to_dict () for item in items },
372- },
373- )
363+ call_args = mock_requests_post .call_args [1 ]
364+ assert call_args ["url" ] == f"http://fake-stac-api/collections/{ job_db_exists .collection_id } /bulk_items"
365+ assert call_args ["auth" ] is None
366+
367+ # Verify the items structure
368+ posted_data = call_args ["json" ]
369+
370+ # Check the structure has the expected nesting
371+ assert "items" in posted_data
372+ items_dict = posted_data ["items" ]
373+
374+ # Verify the single output item
375+ assert "test" in items_dict # This matches the dummy_stac_item fixture
376+ item = items_dict ["test" ]
377+
378+ # Check basic structure
379+ assert item ["id" ] == "test"
380+ assert item ["properties" ]["some_property" ] == "value" # From dummy_stac_item
381+ assert item ["collection" ] == job_db_exists .collection_id
374382
375383 @patch ("requests.post" )
376384 def test_persist_multiple_chunks (self , mock_requests_post , bulk_dataframe , job_db_exists ):
0 commit comments