def test_resize_photo_poorly(): """If we attempt to set the src/dst, we do nothing.""" somepic = get_image_path('mozilla.png') src = tempfile.NamedTemporaryFile(mode='r+w+b', suffix=".png", delete=False, dir=settings.TMP_PATH) shutil.copyfile(somepic, src.name) src_image = Image.open(src.name) assert src_image.size == (339, 128) resize_photo(src.name, src.name) # assert nothing happenned src_image = Image.open(src.name) assert src_image.size == (339, 128)
def test_resize_photo(): somepic = get_image_path('sunbird-small.png') src = tempfile.NamedTemporaryFile(mode='r+w+b', suffix=".png", delete=False, dir=settings.TMP_PATH) dest = tempfile.NamedTemporaryFile(mode='r+w+b', suffix=".png", dir=settings.TMP_PATH) shutil.copyfile(somepic, src.name) src_image = Image.open(src.name) assert src_image.size == (64, 64) resize_photo(src.name, dest.name) # Image is smaller than 200x200 so it should stay the same. dest_image = Image.open(dest.name) assert dest_image.size == (64, 64)
def test_resize_photo(): somepic = get_image_path('sunbird-small.png') src = tempfile.NamedTemporaryFile(mode='r+b', suffix=".png", delete=False, dir=settings.TMP_PATH) dest = tempfile.NamedTemporaryFile(mode='r+b', suffix=".png", dir=settings.TMP_PATH) shutil.copyfile(somepic, src.name) src_image = Image.open(src.name) assert src_image.size == (64, 64) resize_photo(src.name, dest.name) # Image is smaller than 200x200 so it should stay the same. dest_image = Image.open(dest.name) assert dest_image.size == (64, 64)
def test_resize_photo(): somepic = get_image_path('sunbird-small.png') src = tempfile.NamedTemporaryFile(mode='r+w+b', suffix=".png", delete=False, dir=settings.TMP_PATH) dest = tempfile.NamedTemporaryFile(mode='r+w+b', suffix=".png", dir=settings.TMP_PATH) # resize_photo removes the original shutil.copyfile(somepic, src.name) src_image = Image.open(src.name) eq_(src_image.size, (64, 64)) resize_photo(src.name, dest.name, locally=True) # Image is smaller than 200x200 so it should stay the same. dest_image = Image.open(dest.name) eq_(dest_image.size, (64, 64)) assert not os.path.exists(src.name)