22import json
33import pytest
44import StringIO
5+ import os
56
67from py .path import local
78from django .test import TestCase
@@ -239,7 +240,7 @@ def test_edit_event_with_image(admin_user, admin_client, db):
239240 with open (local (__file__ ).dirname + '/../../static/img/team/alja.jpg' ) as fp :
240241 io = StringIO .StringIO ()
241242 io .write (fp .read ())
242- uploaded_picture = InMemoryUploadedFile (io , None , "alja .jpg" , "jpeg" , io .len , None )
243+ uploaded_picture = InMemoryUploadedFile (io , None , "alja17 .jpg" , "jpeg" , io .len , None )
243244 uploaded_picture .seek (0 )
244245
245246 event_data = {
@@ -296,9 +297,14 @@ def test_edit_event_with_image(admin_user, admin_client, db):
296297 assert response_edited .status_code == 302
297298
298299 response = admin_client .get (event .get_absolute_url ())
299- assert 'event_picture/alja ' not in response .content
300+ assert 'event_picture/alja17 ' not in response .content
300301 assert 'event_picture/ercchy' in response .content
301302
303+ #Check if the old event picture has been deleted
304+ old_picture = os .path .isfile (local (__file__ ).dirname + '/../../media/event_picture/alja17.jpg' )
305+
306+ assert not old_picture
307+
302308 event_data = {
303309 'audience' : [6 , 7 ],
304310 'theme' : [3 ,4 ],
@@ -321,3 +327,10 @@ def test_edit_event_with_image(admin_user, admin_client, db):
321327
322328 response = admin_client .get (event .get_absolute_url ())
323329 assert 'event_picture/ercchy' not in response .content
330+
331+
332+
333+
334+
335+
336+
0 commit comments