def test_match_field(): f = SearchHelper(INDEX, search_client=SEARCH_CLIENT) # Basic usage f.match_field("mdf.source_name", "khazana_vasp") res1 = f.search() assert check_field(res1, "mdf.source_name", "khazana_vasp") == 0 # Check that query clears assert f.current_query() == "" # Also checking check_field and no-op f.match_field("material.elements", "Al") f.match_field("", "") res2 = f.search() # Enough so that we'd find at least 1 non-Al example assert check_field(res2, "material.elements", "Al") == 1
def test_current_query(): f = SearchHelper(INDEX, search_client=SEARCH_CLIENT) # Query.clean_query() is already tested, just need to check basic functionality f.match_field("field", "value") assert f.current_query() == "(field:value)"