summaryrefslogtreecommitdiff
path: root/archaeological_finds/tests.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-05-30 16:53:46 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 08:49:36 +0200
commit959d12d757ea9f03e880be165d7cca714b61c27e (patch)
tree455e90208f8ebf92b8a40344d2665dc4f58d2873 /archaeological_finds/tests.py
parent30c086b67ee08bae080f3ee4b19b16aaf9b12bc0 (diff)
downloadIshtar-959d12d757ea9f03e880be165d7cca714b61c27e.tar.bz2
Ishtar-959d12d757ea9f03e880be165d7cca714b61c27e.zip
Fix image search
Diffstat (limited to 'archaeological_finds/tests.py')
-rw-r--r--archaeological_finds/tests.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py
index 097038d8c..1843ff094 100644
--- a/archaeological_finds/tests.py
+++ b/archaeological_finds/tests.py
@@ -553,8 +553,7 @@ class FindSearchTest(FindInit, TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
-
- def testPeriodHierarchicSearch(self):
+ def test_period_hierarchic_search(self):
find = self.finds[0]
c = Client()
@@ -594,7 +593,7 @@ class FindSearchTest(FindInit, TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content)['recordsTotal'], 1)
- def testConservatoryStateHierarchicSearch(self):
+ def test_conservatory_state_hierarchic_search(self):
find = self.finds[0]
c = Client()
cs1 = models.ConservatoryState.objects.all()[0]
@@ -634,6 +633,30 @@ class FindSearchTest(FindInit, TestCase):
self.assertEqual(response.status_code, 200)
self.assertTrue(json.loads(response.content)['recordsTotal'] == 1)
+ def test_image_search(self):
+ c = Client()
+ c.login(username=self.username, password=self.password)
+ search = {'images__pk__isnull': 2} # 2 for nullboolfield is None
+ response = c.get(reverse('get-find'), search)
+ self.assertEqual(response.status_code, 200)
+ res = json.loads(response.content)
+ self.assertEqual(res['recordsTotal'], 0)
+
+ # add an image to the first find
+ image = IshtarImage.objects.create(name="Image!")
+ img = settings.ROOT_PATH + \
+ '../ishtar_common/static/media/images/ishtar-bg.jpg'
+ image.image.save('ishtar-bg.jpg', File(open(img)))
+ models.FindImage.objects.create(
+ item=self.finds[0],
+ image=image
+ )
+ self.finds[0].save()
+ response = c.get(reverse('get-find'), search)
+ self.assertEqual(response.status_code, 200)
+ res = json.loads(response.content)
+ self.assertEqual(res['recordsTotal'], 1)
+
class FindPermissionTest(FindInit, TestCase):
fixtures = FIND_FIXTURES