Skip to content

Commit

Permalink
test: add boolean operator assertion #259
Browse files Browse the repository at this point in the history
  • Loading branch information
MRichards99 committed Nov 19, 2021
1 parent 9a5e02b commit 7b3d039
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions test/search_api/test_search_api_query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
class TestSearchAPIQueryFilterFactory:
@pytest.mark.parametrize(
"test_request_filter, expected_length, expected_fields, expected_operations"
", expected_values",
", expected_values, expected_boolean_operators",
[
pytest.param(
{"filter": {"where": {"title": "My Title"}}},
1,
["title"],
["eq"],
["My Title"],
["and"],
id="Property value, no specified operator",
),
pytest.param(
Expand All @@ -31,6 +32,7 @@ class TestSearchAPIQueryFilterFactory:
["summary"],
["like"],
["My Test Summary"],
["and"],
id="Property value with operator",
),
pytest.param(
Expand All @@ -39,6 +41,7 @@ class TestSearchAPIQueryFilterFactory:
["summary"],
["eq"],
["My Test Summary"],
["and"],
id="AND with single condition, no specified operator",
),
pytest.param(
Expand All @@ -56,6 +59,7 @@ class TestSearchAPIQueryFilterFactory:
["summary", "title"],
["eq", "eq"],
["My Test Summary", "Test title"],
["and", "and"],
id="AND with multiple conditions, no specified operator",
),
pytest.param(
Expand All @@ -64,6 +68,7 @@ class TestSearchAPIQueryFilterFactory:
["value"],
["lt"],
[50],
["and"],
id="AND, single condition with operator",
),
pytest.param(
Expand All @@ -77,10 +82,11 @@ class TestSearchAPIQueryFilterFactory:
},
},
},
1,
2,
["name", "value"],
["like", "gte"],
["Test name", 275],
["and", "and"],
id="AND, multiple conditions with operator",
),
pytest.param(
Expand All @@ -98,10 +104,11 @@ class TestSearchAPIQueryFilterFactory:
},
},
},
1,
2,
["name", "value"],
["like", "gte"],
["Test name", 275],
["and", "and"],
id="Nested AND, multiple conditions with operator",
),
],
Expand All @@ -113,17 +120,23 @@ def test_valid_where_filter(
expected_fields,
expected_operations,
expected_values,
expected_boolean_operators,
):
filters = SearchAPIQueryFilterFactory.get_query_filter(test_request_filter)

assert len(filters) == expected_length
for test_filter, field, operation, value in zip(
filters, expected_fields, expected_operations, expected_values,
for test_filter, field, operation, value, boolean_operator in zip(
filters,
expected_fields,
expected_operations,
expected_values,
expected_boolean_operators,
):
assert isinstance(test_filter, SearchAPIWhereFilter)
assert test_filter.field == field
assert test_filter.operation == operation
assert test_filter.value == value
assert test_filter.boolean_operator == boolean_operator

@pytest.mark.parametrize(
"test_request_filter, expected_length, expected_included_entities, expected_where_filter_data",
Expand Down

0 comments on commit 7b3d039

Please sign in to comment.