diff options
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/tests.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 26da94f60..8d134e519 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -2981,6 +2981,12 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): result = json.loads(response.content.decode()) self.assertEqual(result["recordsTotal"], 1) + # multiple exclude + response = c.get(reverse("get-operation"), + {"search_vector": "-fougere -chateau"}) + result = json.loads(response.content.decode()) + self.assertEqual(result["recordsTotal"], 0) + def test_facet_search_vector(self): ope1 = self.operations[0] ope2 = self.operations[1] @@ -2993,6 +2999,7 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): ope1.save() ope2.year = 2020 ope2.save() + # ope3.year: 2018 data = {"numero_insee": "05000", "name": "Champoleon (test)"} town = self.create_towns(datas=data)[-1] @@ -3010,6 +3017,9 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): villa = models.RemainType.objects.get(txt_idx="villa") ope1.remains.add(villa) + cairn = models.RemainType.objects.get(txt_idx="cairn") + ope2.remains.add(cairn) + ope3.remains.add(cairn) search_period_q = str(pgettext("key for text search", "period")) result = [ @@ -3028,6 +3038,11 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): ] self._test_search(c, result, context="Many integer") + result = [ + ('-{}="{}"'.format(search_year_q, '2042";"2020'), 1), + ] + self._test_search(c, result, context="Exclude many integer") + search_town_q = str(pgettext("key for text search", "town")) town = Town.objects.get(pk=town.pk) result = [ @@ -3044,6 +3059,12 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): ] self._test_search(c, result, context="Period exclude") + search_period_q = str(pgettext("key for text search", "period")) + result = [ + (f'-{search_period_q}="{neo}" -{search_period_q}="{gallo}"', 0), + ] + self._test_search(c, result, context="Many period exclude") + result = [ ( '{}="{}"'.format( @@ -3076,6 +3097,11 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): ('{}="{}"'.format(search_remain_q, str(villa)), 1), ] self._test_search(c, result, context="Non hierarchic remain search") + result = [ + (f'-{search_remain_q}="{cairn}"', 1), + (f'-{search_remain_q}="{cairn}" -{search_remain_q}="{villa}"', 0), + ] + self._test_search(c, result, context="Non hierarchic remain search exclude") # boolean search search_open_q = str(pgettext("key for text search", "is-open")) |