<s> import os <EOL> import shutil <EOL> import tempfile <EOL> from django . conf import settings <EOL> from django . core . files . storage import default_storage as storage <EOL> import pytest <EOL> from nose . tools import eq_ <EOL> from PIL import Image <EOL> from olympia . amo . tests . test_helpers import get_image_path <EOL> from olympia . users . tasks import delete_photo , resize_photo <EOL> pytestmark = pytest . mark . django_db <EOL> def test_delete_photo ( ) : <EOL> dst_path = tempfile . mktemp ( suffix = '<STR_LIT>' , <EOL> dir = settings . TMP_PATH ) <EOL> dst = storage . open ( dst_path , mode = '<STR_LIT:wb>' ) <EOL> with dst : <EOL> dst . write ( '<STR_LIT>' ) <EOL> path = os . path . dirname ( dst_path ) <EOL> settings . USERPICS_PATH = path <EOL> delete_photo ( dst_path ) <EOL> assert not storage . exists ( dst_path ) <EOL> def test_resize_photo ( ) : <EOL> somepic = get_image_path ( '<STR_LIT>' ) <EOL> src = tempfile . NamedTemporaryFile ( mode = '<STR_LIT>' , suffix = "<STR_LIT>" , <EOL> delete = False , dir = settings . TMP_PATH ) <EOL> dest = tempfile . NamedTemporaryFile ( mode = '<STR_LIT>' , suffix = "<STR_LIT>" , <EOL> dir = settings . TMP_PATH ) <EOL> shutil . copyfile ( somepic , src . name ) <EOL> src_image = Image . open ( src . name ) <EOL> eq_ ( src_image . size , ( <NUM_LIT:64> , <NUM_LIT:64> ) ) <EOL> resize_photo ( src . name , dest . name , locally = True ) <EOL> dest_image = Image . open ( dest . name ) <EOL> eq_ ( dest_image . size , ( <NUM_LIT:64> , <NUM_LIT:64> ) ) <EOL> assert not os . path . exists ( src . name ) <EOL> def test_resize_photo_poorly ( ) : <EOL> """<STR_LIT>""" <EOL> somepic = get_image_path ( '<STR_LIT>' ) <EOL> src = tempfile . NamedTemporaryFile ( mode = '<STR_LIT>' , suffix = "<STR_LIT>" , <EOL> delete = False , dir = settings . TMP_PATH ) <EOL> shutil . copyfile ( somepic , src . name ) <EOL> src_image = Image . open ( src . name ) <EOL> eq_ ( src_image . size , ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> resize_photo ( src . name , src . name ) <EOL> src_image = Image . open ( src . name ) <EOL> eq_ ( src_image . size , ( <NUM_LIT> , <NUM_LIT> ) ) </s>
