@@ -677,54 +677,39 @@ async def test_queryables_enum_platform(
677677
678678
679679@pytest .mark .asyncio
680- async def test_search_filter_ext_or_condition (app_client , ctx ):
681- """Test that OR conditions work correctly in filters ."""
682- # This test verifies that OR conditions work by checking for items that match
683- # either of two conditions where only one should match the test item
680+ async def test_search_filter_ext_or_with_must_condition (app_client , ctx ):
681+ """Test that OR conditions work correctly when combined with MUST conditions ."""
682+ # This test verifies that when combining MUST and SHOULD clauses,
683+ # we still require at least one SHOULD condition to match
684684 params = {
685685 "filter" : {
686- "op" : "or " ,
686+ "op" : "and " ,
687687 "args" : [
688+ # MUST condition (matches all test items)
689+ {"op" : ">=" , "args" : [{"property" : "eo:cloud_cover" }, 0 ]},
690+ # OR condition (only some items match)
688691 {
689- "op" : "<" ,
690- "args" : [
691- {"property" : "eo:cloud_cover" },
692- 0 , # This condition should NOT match (cloud_cover is 0, not < 0)
693- ],
694- },
695- {
696- "op" : "=" ,
692+ "op" : "or" ,
697693 "args" : [
698- {"property" : "properties.proj:epsg" },
699- 32756 , # This condition SHOULD match
694+ {"op" : "<" , "args" : [{"property" : "eo:cloud_cover" }, 10 ]},
695+ {
696+ "op" : "=" ,
697+ "args" : [{"property" : "properties.proj:epsg" }, 99999 ],
698+ },
700699 ],
701700 },
702701 ],
703702 }
704703 }
705704
706- # First verify the test item matches exactly one of the conditions
707- props = ctx .item .get ("properties" , {})
708- matches = [
709- props .get ("eo:cloud_cover" , 100 ) < 0 , # Should be False
710- props .get ("proj:epsg" ) == 32756 , # Should be True
711- ]
712- assert sum (matches ) == 1 , "Test item should match exactly one condition"
713-
714- # Now test the API
705+ # Test the API
715706 resp = await app_client .post ("/search" , json = params )
716707 assert resp .status_code == 200
717708 resp_json = resp .json ()
718709
719- # Should find at least the test item
720- assert len (resp_json ["features" ]) >= 1
721-
722- # Verify at least one feature matches one of the conditions
723- matched = False
710+ # Should only find items where cloud_cover < 10 (second condition is false for all)
724711 for feature in resp_json ["features" ]:
725712 props = feature .get ("properties" , {})
726- if props .get ("eo:cloud_cover" , 100 ) < 0 or props .get ("proj:epsg" ) == 32756 :
727- matched = True
728- break
729-
730- assert matched , "No features matched the OR condition"
713+ assert (
714+ props .get ("eo:cloud_cover" , 100 ) < 10
715+ ), "Items should only be returned if they match at least one OR condition"
0 commit comments