summaryrefslogtreecommitdiff
path: root/archaeological_operations/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-15 14:12:51 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-15 14:12:51 +0200
commit705d2f787cdf29aa4524a45e0399cd950441fb51 (patch)
tree2f1d2050b699b949c0769c5a6ddb286de69c80f6 /archaeological_operations/tests.py
parentc1dc72c74bda015673b2adc0d03d66dada52f4bf (diff)
downloadIshtar-705d2f787cdf29aa4524a45e0399cd950441fb51.tar.bz2
Ishtar-705d2f787cdf29aa4524a45e0399cd950441fb51.zip
Fix tests
Diffstat (limited to 'archaeological_operations/tests.py')
-rw-r--r--archaeological_operations/tests.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index d7cf67849..86fbd0d7b 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -1053,7 +1053,7 @@ class OperationTest(TestCase, OperationInitTest):
operation.comment = u"Zardoz"
operation.code_patriarche = u"HUIAAA5"
operation.save()
- for key in ('old', 'op2010', 'dirty', 'daisy', "'2010'", "zardoz",
+ for key in ('old', 'dirty', 'daisy', "'2010'", "zardoz",
"huiaaa5"):
self.assertIn(key, operation.search_vector)
@@ -1474,7 +1474,7 @@ class OperationSearchTest(TestCase, OperationInitTest):
response = c.get(reverse('get-operation'), {'year': '2010'})
self.assertEqual(json.loads(response.content)['recordsTotal'], 2)
response = c.get(reverse('get-operation'),
- {'operator': self.orgas[0].pk})
+ {'operator': self.orgas[0].name})
result = json.loads(response.content)
self.assertEqual(result['recordsTotal'], 3)
@@ -1643,12 +1643,14 @@ class OperationSearchTest(TestCase, OperationInitTest):
relation_type=rel1)
return rel1, rel2
- def testRelatedSearch(self):
+ def test_related_search(self):
c = Client()
rel1, rel2 = self.create_relations()
self.operations[1].year = 2011
self.operations[1].save()
- search = {'year': '2010', 'relation_types_0': rel2.pk}
+ search = {
+ 'search_vector': 'year=2010 relation-types="{}"'.format(rel2.name)
+ }
response = c.get(reverse('get-operation'), search)
# no result when no authentification
self.assertTrue(not json.loads(response.content))
@@ -1772,21 +1774,30 @@ class OperationPermissionTest(TestCase, OperationInitTest):
response = c.get(reverse('get-operation'), {'year': '2010'})
# only one "own" operation available
self.assertTrue(json.loads(response.content))
- self.assertTrue(json.loads(response.content)['recordsTotal'] == 1)
+ self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
response = c.get(reverse('get-operation'),
- {'operator': self.orgas[0].pk})
- self.assertTrue(json.loads(response.content)['recordsTotal'] == 1)
+ {'operator': self.orgas[0].name})
+ self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
+ response = c.get(reverse('get-operation'),
+ {'search_vector': 'operator="{}"'.format(
+ self.orgas[0].name)})
+ self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
# area filter
c = Client()
c.login(username=self.alt_username2, password=self.alt_password2)
- response = c.get(reverse('get-operation'), {'year': '2010'})
+ response = c.get(reverse('get-operation'),
+ {'year': '2010'})
# only one "own" operation available
self.assertTrue(json.loads(response.content))
- self.assertTrue(json.loads(response.content)['recordsTotal'] == 1)
+ self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
response = c.get(reverse('get-operation'),
- {'operator': self.orgas[0].pk})
- self.assertTrue(json.loads(response.content)['recordsTotal'] == 1)
+ {'operator': self.orgas[0].name})
+ self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
+ response = c.get(reverse('get-operation'),
+ {'search_vector': 'operator="{}"'.format(
+ self.orgas[0].name)})
+ self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
def test_own_modify(self):
operation_pk1 = self.operations[0].pk