예제 #1
0
 def test_thumbnail_size(self):
     img_name, r = self.upload()
     # get the thumbnail link
     self.img_id = test_utils.get_img_id(img_name)
     r = self.client.get('/embed/thumbnail/%s' % (self.img_id))
     self.assertEquals(r.status_code, 301)
     imgio = test_utils.download_image(r.location)
     img = Image.open(imgio)
     self.assertEquals('%sx%s' % img.size, app.config.get('THUMBNAIL_SIZE'))
예제 #2
0
 def test_resize3_file(self):
     # non resizable images
     file_name, r = self.upload('../imgee/static/img/imgee.svg')
     file_id = test_utils.get_img_id(file_name)
     r1 = self.client.get('/embed/file/%s' % (file_id))
     r2 = self.client.get('/embed/file/%s?size=100x200' % (file_id))
     self.assertEquals(r1.status_code, 301)
     self.assertEquals(r2.status_code, 301)
     self.assertEquals(r1.location, r2.location)
     self.assertTrue(file_id in r2.location)
예제 #3
0
    def test_resize_single_dimension(self):
        img_name, r = self.upload()
        img_w, img_h = self.get_image_size()

        self.img_id = test_utils.get_img_id(img_name)
        r = self.client.get('/embed/file/%s?size=100' % (self.img_id))
        self.assertEquals(r.status_code, 301)
        resized_img = test_utils.download_image(r.location)
        resized_w, resized_h = self.get_image_size(resized_img)
        self.assertEquals(resized_w, 100)
        # check aspect ratio
        self.assertEquals(int(img_w/resized_w), int(img_h/resized_h))
예제 #4
0
    def test_delete(self):
        filetitle, r = self.upload()
        self.img_id = test_utils.get_img_id(filetitle)

        # check if the file and thumbnail exists
        self.assertTrue(self.exists_on_media_domain(self.img_id))
        self.assertTrue(self.thumbnails_exists_on_media_domain(self.img_id))

        r = self.client.post('/%s/delete/%s' % (self.test_user_name, self.img_id))

        # check if the file exists now
        r = self.client.get('/embed/file/%s' % (self.img_id))
        self.assertEquals(r.status_code, 404)

        # check if the thumbnail exists
        r = self.client.get('/embed/thumbnail/%s' % (self.img_id))
        self.assertEquals(r.status_code, 404)
예제 #5
0
 def setUp(self):
     super(TestUpload, self).setUp()
     self.filetitle, self.r = self.upload()
     self.img_id = test_utils.get_img_id(self.filetitle)