예제 #1
0
 def test_construction_from_file(self):
     """Image(path) constructor produces correct attribute values"""
     # exercise ---------------------
     partname = PackURI('/ppt/media/image1.jpeg')
     image = Image.new(partname, test_image_path)
     # verify -----------------------
     assert_that(image.ext, is_(equal_to('jpeg')))
     assert_that(image.content_type, is_(equal_to('image/jpeg')))
     assert_that(len(image._blob), is_(equal_to(3277)))
     assert_that(image._desc, is_(equal_to('python-icon.jpeg')))
예제 #2
0
 def test_construction_from_file(self):
     """Image(path) constructor produces correct attribute values"""
     # exercise ---------------------
     partname = PackURI('/ppt/media/image1.jpeg')
     image = Image.new(partname, test_image_path)
     # verify -----------------------
     assert image.ext == 'jpeg'
     assert image.content_type == 'image/jpeg'
     assert len(image._blob) == 3277
     assert image._desc == 'python-icon.jpeg'
예제 #3
0
 def test_construction_from_file(self):
     """Image(path) constructor produces correct attribute values"""
     # exercise ---------------------
     partname = PackURI('/ppt/media/image1.jpeg')
     image = Image.new(partname, test_image_path)
     # verify -----------------------
     assert image.ext == 'jpeg'
     assert image.content_type == 'image/jpeg'
     assert len(image._blob) == 3277
     assert image._desc == 'python-icon.jpeg'
예제 #4
0
 def test_construction_from_stream(self):
     """Image(stream) construction produces correct attribute values"""
     # exercise ---------------------
     partname = PackURI('/ppt/media/image1.jpeg')
     with open(test_image_path, 'rb') as f:
         stream = StringIO(f.read())
     image = Image.new(partname, stream)
     # verify -----------------------
     assert image.ext == 'jpg'
     assert image.content_type == 'image/jpeg'
     assert len(image._blob) == 3277
     assert image._desc == 'image.jpg'
예제 #5
0
 def test_construction_from_stream(self):
     """Image(stream) construction produces correct attribute values"""
     # exercise ---------------------
     partname = PackURI('/ppt/media/image1.jpeg')
     with open(test_image_path, 'rb') as f:
         stream = StringIO(f.read())
     image = Image.new(partname, stream)
     # verify -----------------------
     assert_that(image.ext, is_(equal_to('jpg')))
     assert_that(image.content_type, is_(equal_to('image/jpeg')))
     assert_that(len(image._blob), is_(equal_to(3277)))
     assert_that(image._desc, is_(equal_to('image.jpg')))
예제 #6
0
 def test__scale_calculates_correct_dimensions(self):
     """Image._scale() calculates correct dimensions"""
     # setup ------------------------
     test_cases = (((None, None), (Px(204), Px(204))), ((1000, None),
                                                        (1000, 1000)),
                   ((None, 3000), (3000, 3000)), ((3337, 9999), (3337,
                                                                 9999)))
     partname = PackURI('/ppt/media/image1.png')
     image = Image.new(partname, test_image_path)
     # verify -----------------------
     for params, expected in test_cases:
         width, height = params
         assert image._scale(width, height) == expected
예제 #7
0
 def test__scale_calculates_correct_dimensions(self):
     """Image._scale() calculates correct dimensions"""
     # setup ------------------------
     test_cases = (
         ((None, None), (Px(204), Px(204))),
         ((1000, None), (1000, 1000)),
         ((None, 3000), (3000, 3000)),
         ((3337, 9999), (3337, 9999)))
     partname = PackURI('/ppt/media/image1.png')
     image = Image.new(partname, test_image_path)
     # verify -----------------------
     for params, expected in test_cases:
         width, height = params
         assert_that(image._scale(width, height), is_(equal_to(expected)))
예제 #8
0
 def test__size_returns_image_native_pixel_dimensions(self):
     """Image._size is width, height tuple of image pixel dimensions"""
     partname = PackURI('/ppt/media/image1.png')
     image = Image.new(partname, test_image_path)
     assert image._size == (204, 204)
예제 #9
0
 def test_construction_from_file_raises_on_bad_path(self):
     """Image(path) constructor raises on bad path"""
     partname = PackURI('/ppt/media/image1.jpeg')
     with self.assertRaises(IOError):
         Image.new(partname, 'foobar27.png')
예제 #10
0
 def test__size_returns_image_native_pixel_dimensions(self):
     """Image._size is width, height tuple of image pixel dimensions"""
     partname = PackURI('/ppt/media/image1.png')
     image = Image.new(partname, test_image_path)
     assert_that(image._size, is_(equal_to((204, 204))))
예제 #11
0
 def test_construction_from_file_raises_on_bad_path(self):
     """Image(path) constructor raises on bad path"""
     partname = PackURI('/ppt/media/image1.jpeg')
     with self.assertRaises(IOError):
         Image.new(partname, 'foobar27.png')