From ebc72b876824b333bed368afaf3f700736b6b390 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 28 Oct 2024 12:22:50 +0100 Subject: ✨ search add OR "||" - search refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_operations/tests.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'archaeological_operations/tests.py') diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 10bc52967..bfd2a162b 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -3070,6 +3070,23 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): result = json.loads(response.content.decode()) self.assertEqual(result["recordsTotal"], 1) + def test_or_search_vector(self): + operation_1 = models.Operation.objects.get(pk=self.operations[0].pk) + operation_2 = models.Operation.objects.get(pk=self.operations[1].pk) + operation_1.common_name = "Château de Fougères" + operation_1.save() + operation_2.code_patriarche = "OA4242" + operation_2.save() + + c = Client() + c.login(username=self.username, password=self.password) + + patriarche_key = pgettext_lazy("key for text search", "patriarche") + name_key = pgettext_lazy("key for text search", "name") + request = f'{patriarche_key}="OA4242" || {name_key}="{operation_1.common_name}"' + response = c.get(reverse("get-operation"), {"search_vector": request}) + self.assertEqual(json.loads(response.content.decode())["recordsTotal"], 2) + def test_complex_search_vector(self): c = Client() c.login(username=self.username, password=self.password) -- cgit v1.2.3