Skip to content

Commit

Permalink
tests: add more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Sep 25, 2023
1 parent b70bbc9 commit f710aa0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 2 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
1. Make it possible to search nutrient values (ES object type)
2. Index taxonomies in separate indices and allow to do search-as-you-type on taxonomies
4. Remove obsolete products from collection
5. Fix luqum parser that search in "text" field when searching: '"match phrase"'
1. Index taxonomies in separate indices and allow to do search-as-you-type on taxonomies
2. Fix luqum parser that search in "text" field when searching: '"match phrase"'
8 changes: 7 additions & 1 deletion tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ def test_transform(self, query: str, expected: str):
{"term": {"states_tags": {"value": "en:spain"}}},
"",
),
(
"nutriments.salt_100g:[2 TO *]",
{"range": {"nutriments.salt_100g": {"gte": "2"}}},
"",
),
],
)
def test_parse_lucene_dsl_query(
q: str, expected_filter_clauses: list[JSONType], expected_remaining_terms: str
):
query_builder = ElasticsearchQueryBuilder(
default_operator=ElasticsearchQueryBuilder.MUST,
not_analyzed_fields=["states_tags", "labels_tags"],
not_analyzed_fields=["states_tags", "labels_tags", "countries_tags"],
object_fields=["nutriments", "nutriments.salt_100g"],
)
filter_clauses, remaining_terms = parse_lucene_dsl_query(q, query_builder)
assert filter_clauses == expected_filter_clauses
Expand Down

0 comments on commit f710aa0

Please sign in to comment.