From cbe5632f6be526afa0e2ff0bb58c0cad3070b8b8 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 14 Nov 2023 18:53:00 +0100 Subject: 🐛 search: fix -type="*" search for types with no hierarchy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_operations/tests.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'archaeological_operations/tests.py') diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index 331c24659..afa484839 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -3190,6 +3190,25 @@ class OperationSearchTest(TestCase, OperationInitTest, SearchText): ] self._test_search(c, result, context="Facet search with * characters") + def test_search_has_type_filled_or_not(self): + c = Client() + c.login(username=self.username, password=self.password) + ope = self.operations[0] + ope.report_processing = models.ReportState.objects.all()[0] + ope.save() + final_neo = models.Period.objects.get(txt_idx="final-neolithic") + ope.periods.add(final_neo) + nb = models.Operation.objects.count() + self.assertTrue(nb > 1) + + search_name_q = str(pgettext("key for text search", "report-processing")) + result = [(f'{search_name_q}="*"', 1), (f'-{search_name_q}="*"', nb - 1)] + self._test_search(c, result, context="Search filled or not - simple type") + + search_name_q = str(pgettext_lazy("key for text search", "period")) + result = [(f'{search_name_q}="*"', 1), (f'-{search_name_q}="*"', nb - 1)] + self._test_search(c, result, context="Search filled or not - hierarchical type") + def test_hierarchic_search(self): ope = self.operations[1] c = Client() -- cgit v1.2.3