22import json
33import pytest
44import StringIO
5+ import os
56
67from py .path import local
78from django .test import TestCase
@@ -209,7 +210,7 @@ def test_edit_event_with_image(admin_user, admin_client, db):
209210 with open (local (__file__ ).dirname + '/../../static/img/team/alja.jpg' ) as fp :
210211 io = StringIO .StringIO ()
211212 io .write (fp .read ())
212- uploaded_picture = InMemoryUploadedFile (io , None , "alja .jpg" , "jpeg" , io .len , None )
213+ uploaded_picture = InMemoryUploadedFile (io , None , "alja17 .jpg" , "jpeg" , io .len , None )
213214 uploaded_picture .seek (0 )
214215
215216 event_data = {
@@ -266,9 +267,14 @@ def test_edit_event_with_image(admin_user, admin_client, db):
266267 assert response_edited .status_code == 302
267268
268269 response = admin_client .get (event .get_absolute_url ())
269- assert 'event_picture/alja ' not in response .content
270+ assert 'event_picture/alja17 ' not in response .content
270271 assert 'event_picture/ercchy' in response .content
271272
273+ #Check if the old event picture has been deleted
274+ old_picture = os .path .isfile (local (__file__ ).dirname + '/../../media/event_picture/alja17.jpg' )
275+
276+ assert not old_picture
277+
272278 event_data = {
273279 'audience' : [6 , 7 ],
274280 'theme' : [3 ,4 ],
@@ -291,3 +297,4 @@ def test_edit_event_with_image(admin_user, admin_client, db):
291297
292298 response = admin_client .get (event .get_absolute_url ())
293299 assert 'event_picture/ercchy' not in response .content
300+
0 commit comments