Пример #1
0
    def test_modifying_existing_image_to_small_image(self):
        response = self.post(self.base_uri, {'Content-Type': 'image/jpeg'}, valid_image())
        expect(response.code).to_equal(201)

        location = response.headers['Location']
        response = self.put(location, {'Content-Type': 'image/jpeg'}, too_small_image())
        expect(response.code).to_equal(412)

        expected_path = self.get_path_from_location(location)
        expected_path = self.upload_storage.path_on_filesystem(expected_path)
        expect(expected_path).to_exist()
        expect(expected_path).to_be_the_same_as(valid_image_path)
Пример #2
0
    def test_modifying_existing_image_to_small_image(self):
        response = self.post(self.base_uri, {'Content-Type': 'image/jpeg'},
                             valid_image())
        expect(response.code).to_equal(201)

        location = response.headers['Location']
        response = self.put(location, {'Content-Type': 'image/jpeg'},
                            too_small_image())
        expect(response.code).to_equal(412)

        expected_path = self.get_path_from_location(location)
        expected_path = self.upload_storage.path_on_filesystem(expected_path)
        expect(expected_path).to_exist()
        expect(expected_path).to_be_the_same_as(valid_image_path)
Пример #3
0
    async def test_modifying_existing_image_to_small_image(self):
        response = await self.async_post(self.base_uri,
                                         {"Content-Type": "image/jpeg"},
                                         valid_image())
        expect(response.code).to_equal(201)

        location = response.headers["Location"]
        response = await self.async_put(location,
                                        {"Content-Type": "image/jpeg"},
                                        too_small_image())
        expect(response.code).to_equal(412)

        expected_path = self.get_path_from_location(location)
        expected_path = self.upload_storage.path_on_filesystem(expected_path)
        expect(expected_path).to_exist()
        expect(expected_path).to_be_the_same_as(VALID_IMAGE_PATH)
Пример #4
0
    def test_can_modify_existing_image(self):
        filename = self.default_filename + '.jpg'
        response = self.post(self.base_uri, {'Content-Type': 'image/jpeg'}, valid_image())
        location = response.headers['Location']
        response = self.put(location, {'Content-Type': 'image/jpeg'}, too_small_image())

        expect(response.code).to_equal(204)

        id_should_exist = re.compile(self.base_uri + r'/([^\/]{32})/' + filename).search(location).group(1)
        expected_path = self.upload_storage.path_on_filesystem(id_should_exist)
        expect(expected_path).to_exist()
        expect(expected_path).to_be_the_same_as(too_small_image_path)

        id_shouldnt_exist = re.compile(self.base_uri + r'/(.*)').search(location).group(1)
        expected_path = self.upload_storage.path_on_filesystem(id_shouldnt_exist)
        expect(expected_path).not_to_exist()
Пример #5
0
    def test_can_modify_existing_image(self):
        filename = self.default_filename + '.jpg'
        response = self.post(self.base_uri, {'Content-Type': 'image/jpeg'},
                             valid_image())
        location = response.headers['Location']
        response = self.put(location, {'Content-Type': 'image/jpeg'},
                            too_small_image())

        expect(response.code).to_equal(204)

        id_should_exist = re.compile(self.base_uri + r'/([^\/]{32})/' +
                                     filename).search(location).group(1)
        expected_path = self.upload_storage.path_on_filesystem(id_should_exist)
        expect(expected_path).to_exist()
        expect(expected_path).to_be_the_same_as(too_small_image_path)

        id_shouldnt_exist = re.compile(self.base_uri +
                                       r'/(.*)').search(location).group(1)
        expected_path = self.upload_storage.path_on_filesystem(
            id_shouldnt_exist)
        expect(expected_path).not_to_exist()
Пример #6
0
    async def test_can_modify_existing_image(self):
        filename = self.default_filename + ".jpg"
        response = await self.async_post(self.base_uri,
                                         {"Content-Type": "image/jpeg"},
                                         valid_image())
        location = response.headers["Location"]
        response = await self.async_put(location,
                                        {"Content-Type": "image/jpeg"},
                                        too_small_image())

        expect(response.code).to_equal(204)

        id_should_exist = (re.compile(self.base_uri + r"/([^\/]{32})/" +
                                      filename).search(location).group(1))
        expected_path = self.upload_storage.path_on_filesystem(id_should_exist)
        expect(expected_path).to_exist()
        expect(expected_path).to_be_the_same_as(TOO_SMALL_IMAGE_PATH)

        id_shouldnt_exist = (re.compile(self.base_uri +
                                        r"/(.*)").search(location).group(1))
        expected_path = self.upload_storage.path_on_filesystem(
            id_shouldnt_exist)
        expect(expected_path).not_to_exist()
Пример #7
0
 def test_posting_a_too_small_image_from_html_form_fails(self):
     image = ('media', u'crocodile9999.jpg', too_small_image())
     response = self.post_files(self.base_uri, {}, (image, ))
     expect(response.code).to_equal(412)
Пример #8
0
 def test_posting_a_too_small_image_fails(self):
     response = self.post(self.base_uri, {'Content-Type': 'image/jpeg'},
                          too_small_image())
     expect(response.code).to_equal(412)
Пример #9
0
 async def test_posting_a_too_small_image_from_html_form_fails(self):
     image = ("media", "crocodile9999.jpg", too_small_image())
     response = await self.async_post_files(self.base_uri, {}, (image, ))
     expect(response.code).to_equal(412)
Пример #10
0
 async def test_posting_a_too_small_image_fails(self):
     response = await self.async_post(self.base_uri,
                                      {"Content-Type": "image/jpeg"},
                                      too_small_image())
     expect(response.code).to_equal(412)
Пример #11
0
 def test_posting_a_too_small_image_from_html_form_fails(self):
     image = ('media', u'crocodile9999.jpg', too_small_image())
     response = self.post_files(self.base_uri, {}, (image, ))
     expect(response.code).to_equal(412)
Пример #12
0
 def test_posting_a_too_small_image_fails(self):
     response = self.post(self.base_uri, {'Content-Type': 'image/jpeg'}, too_small_image())
     expect(response.code).to_equal(412)