Skip to content

Commit

Permalink
fix cache issue in parallel testing context
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Nov 7, 2024
1 parent acaedec commit 55641f7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lemarche/www/siaes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def setUpTestData(cls):

def test_search_num_queries(self):
url = reverse("siae:search_results")

# fix cache issue in parallel testing context, "SELECT 'django_site'" query appears additionally otherwise
self.client.get(url)

with self.assertNumQueries(12):
response = self.client.get(url)
siaes = list(response.context["siaes"])
Expand Down Expand Up @@ -1032,11 +1036,14 @@ def test_search_query_no_result(self):
mock_siaes_similarity_search.assert_called_once()

def test_search_query_with_results(self):
with mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search"
) as mock_siaes_similarity_search, mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search_with_city"
) as mock_siaes_similarity_search_with_city:
with (
mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search"
) as mock_siaes_similarity_search,
mock.patch(
"lemarche.utils.apis.api_elasticsearch.siaes_similarity_search_with_city"
) as mock_siaes_similarity_search_with_city,
):
mock_siaes_similarity_search.return_value = [self.siae_two.pk, self.siae_three.pk, self.siae_four.pk]
url = self.url + "?semantic_q=entretien espace vert&id_semantic_city_name=&semantic_city="
response = self.client.get(url)
Expand Down

0 comments on commit 55641f7

Please sign in to comment.