From 048e157bf9d288b6500191fdbba8ea6fa49a62c9 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 3 Jul 2018 13:06:01 +0200 Subject: Search: manage exclude - refactor search (refs #4180) --- archaeological_operations/tests.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'archaeological_operations/tests.py') diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index f67ce5adc..4a27660d0 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1542,6 +1542,12 @@ class OperationSearchTest(TestCase, OperationInitTest): result = json.loads(response.content) self.assertEqual(result['recordsTotal'], 3) + # exclude + response = c.get(reverse('get-operation'), + {'search_vector': '-fougere'}) + result = json.loads(response.content) + self.assertEqual(result['recordsTotal'], 1) + def test_facet_search_vector(self): ope1 = self.operations[0] ope2 = self.operations[1] @@ -1577,6 +1583,13 @@ class OperationSearchTest(TestCase, OperationInitTest): result = json.loads(response.content) self.assertEqual(result['recordsTotal'], 2) + # exclude + search = {'search_vector': u'-{}="{}"'.format(search_q, neo.label)} + response = c.get(reverse('get-operation'), search) + self.assertEqual(response.status_code, 200) + result = json.loads(response.content) + self.assertEqual(result['recordsTotal'], 1) + # OR search = {'search_vector': u'{}="{}";"{}"'.format(search_q, neo.label, gallo.label)} @@ -1585,6 +1598,14 @@ class OperationSearchTest(TestCase, OperationInitTest): result = json.loads(response.content) self.assertEqual(result['recordsTotal'], 3) + # OR - alt syntax + search = {'search_vector': u'{}="{}" {}="{}"'.format( + search_q, neo.label, search_q, gallo.label)} + response = c.get(reverse('get-operation'), search) + self.assertEqual(response.status_code, 200) + result = json.loads(response.content) + self.assertEqual(result['recordsTotal'], 3) + # open search '*' search = {'search_vector': u'{}="{}*"'.format(search_q, neo.label[:3])} response = c.get(reverse('get-operation'), search) -- cgit v1.2.3