From 91c0aec5a99194f6fd1927b80354a56e135c1baf Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 12 Nov 2020 12:17:49 +0100 Subject: Tests: search hierarchic text test --- ishtar_common/tests.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'ishtar_common/tests.py') diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 1d211c91b..122f29d92 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -236,6 +236,24 @@ class UtilsTest(TestCase): self.assertEqual(response.status_code, 302) +class SearchText: + SEARCH_URL = '' + + def _test_search(self, client, result, context=""): + assert self.SEARCH_URL + for q, expected_result in result: + search = {'search_vector': q} + response = client.get(reverse(self.SEARCH_URL), search) + self.assertEqual(response.status_code, 200) + res = json.loads(response.content.decode()) + msg = "{} result(s) where expected for search: {} - found {}" \ + "".format(expected_result, q, res['recordsTotal']) + if context: + msg = context + " - " + msg + self.assertEqual(res['recordsTotal'], expected_result, + msg=msg) + + class CommandsTestCase(TestCase): fixtures = [settings.ROOT_PATH + '../ishtar_common/fixtures/test_towns.json'] -- cgit v1.2.3