Exemple #1
0
    def test_delete_file(self):
        for file in self.files:
            delete(file, commit=False)

        db.session.commit()

        for file in self.files:
            with app.test_request_context('/'):
                resp = requests.get(get_image_url(file))
                self.assertEquals(resp.status_code, 403)  # S3 throws 403 for non existing files
Exemple #2
0
def get_image(image):
    size = request.args.get('size')
    retries = 0
    while retries < 15:
        try:
            image_url = utils.get_image_url(image, size)
        except async.StillProcessingException:
            time.sleep(1)
            retries += 1
        else:
            if image_url == get_no_previews_url(size):
                code = 302
            else:
                code = 301
            return redirect(image_url, code=code)
Exemple #3
0
 def test_save_file(self):
     with app.test_request_context('/'):
         for file in self.files:
             resp = requests.get(get_image_url(file))
             self.assertEquals(resp.status_code, 200)
             self.assertEquals(resp.headers.get('Content-Type', ''), file.mimetype)
Exemple #4
0
 def generate_thumb(image, size):
     try:
         utils.get_image_url(image, size)
     except async.StillProcessingException:
         pass