File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -395,21 +395,30 @@ def test_filter_by_buyer_and_seller(self):
395395 results = list (cms )
396396 assert len (results ) > 0 , "Expected at least one cargo movement"
397397
398+ found_matching_trade = False
398399 for cm in results :
399- assert "trades" in cm
400- assert cm ["trades" ]
400+ if "trades" in cm and cm ["trades" ]:
401+ # At least one trade should have the filtered buyer_id
402+ buyer_ids = [
403+ t .get ("buyer_id" )
404+ for t in cm ["trades" ]
405+ if t .get ("buyer_id" )
406+ ]
407+ if buyer_id in buyer_ids :
408+ found_matching_trade = True
401409
402- # At least one trade should have the filtered buyer_id
403- buyer_ids = [
404- t .get ("buyer_id" ) for t in cm ["trades" ] if t .get ("buyer_id" )
405- ]
406- assert buyer_id in buyer_ids , f"Expected { buyer_id } in trades"
407-
408- # At least one trade should have the filtered seller_id
409- seller_ids = [
410- t .get ("seller_id" ) for t in cm ["trades" ] if t .get ("seller_id" )
411- ]
412- assert seller_id in seller_ids , f"Expected { seller_id } in trades"
410+ # At least one trade should have the filtered seller_id
411+ seller_ids = [
412+ t .get ("seller_id" )
413+ for t in cm ["trades" ]
414+ if t .get ("seller_id" )
415+ ]
416+ if seller_id in seller_ids :
417+ found_matching_trade = True
418+
419+ assert (
420+ found_matching_trade
421+ ), "Expected at least one trade with matching buyer_id or seller_id"
413422
414423 def test_filter_exclude_buyer_and_seller (self ):
415424 # Exclude BP as buyer, Atlantic LNG as seller
You can’t perform that action at this time.
0 commit comments