Skip to content

Commit

Permalink
Update the tests
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <[email protected]>
  • Loading branch information
obulat committed Nov 15, 2023
1 parent e7fb1a3 commit 1d60c9d
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions api/test/unit/controllers/test_search_controller_search_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from api.controllers import search_controller
from api.controllers.search_controller import DEFAULT_SQS_FLAGS


pytestmark = pytest.mark.django_db
Expand Down Expand Up @@ -62,6 +63,7 @@ def test_create_search_query_q_search_no_filters(media_type_config):
"default_operator": "AND",
"fields": ["title", "description", "tags.name"],
"query": "cat",
"flags": DEFAULT_SQS_FLAGS,
}
}
],
Expand All @@ -71,6 +73,7 @@ def test_create_search_query_q_search_no_filters(media_type_config):
"boost": 10000,
"fields": ["title"],
"query": "cat",
"flags": DEFAULT_SQS_FLAGS,
}
},
{"rank_feature": {"boost": 10000, "field": "standardized_popularity"}},
Expand All @@ -95,6 +98,7 @@ def test_create_search_query_q_search_with_quotes_adds_exact_suffix(media_type_c
"fields": ["title", "description", "tags.name"],
"query": '"The cutest cat"',
"quote_field_suffix": ".exact",
"flags": DEFAULT_SQS_FLAGS,
}
}
],
Expand All @@ -104,6 +108,7 @@ def test_create_search_query_q_search_with_quotes_adds_exact_suffix(media_type_c
"boost": 10000,
"fields": ["title"],
"query": "The cutest cat",
"flags": DEFAULT_SQS_FLAGS,
}
},
{"rank_feature": {"boost": 10000, "field": "standardized_popularity"}},
Expand Down Expand Up @@ -143,6 +148,7 @@ def test_create_search_query_q_search_with_filters(image_media_type_config):
"default_operator": "AND",
"fields": ["title", "description", "tags.name"],
"query": "cat",
"flags": DEFAULT_SQS_FLAGS,
}
}
],
Expand All @@ -152,6 +158,7 @@ def test_create_search_query_q_search_with_filters(image_media_type_config):
"boost": 10000,
"fields": ["title"],
"query": "cat",
"flags": DEFAULT_SQS_FLAGS,
}
},
{"rank_feature": {"boost": 10000, "field": "standardized_popularity"}},
Expand Down Expand Up @@ -179,10 +186,23 @@ def test_create_search_query_non_q_query(image_media_type_config):
"simple_query_string": {
"fields": ["creator"],
"query": "Artist From Openverse",
"flags": DEFAULT_SQS_FLAGS,
}
},
{
"simple_query_string": {
"fields": ["title"],
"query": "kitten🐱",
"flags": DEFAULT_SQS_FLAGS,
}
},
{
"simple_query_string": {
"fields": ["tags.name"],
"query": "cute",
"flags": DEFAULT_SQS_FLAGS,
}
},
{"simple_query_string": {"fields": ["title"], "query": "kitten🐱"}},
{"simple_query_string": {"fields": ["tags.name"], "query": "cute"}},
],
"should": [
{"rank_feature": {"boost": 10000, "field": "standardized_popularity"}},
Expand Down

0 comments on commit 1d60c9d

Please sign in to comment.