diff options
Diffstat (limited to 'archaeological_finds/tests.py')
| -rw-r--r-- | archaeological_finds/tests.py | 29 | 
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  | 
