2
2
import json
3
3
import pytest
4
4
import StringIO
5
+ import os
5
6
6
7
from py .path import local
7
8
from django .test import TestCase
@@ -209,7 +210,7 @@ def test_edit_event_with_image(admin_user, admin_client, db):
209
210
with open (local (__file__ ).dirname + '/../../static/img/team/alja.jpg' ) as fp :
210
211
io = StringIO .StringIO ()
211
212
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 )
213
214
uploaded_picture .seek (0 )
214
215
215
216
event_data = {
@@ -266,9 +267,14 @@ def test_edit_event_with_image(admin_user, admin_client, db):
266
267
assert response_edited .status_code == 302
267
268
268
269
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
270
271
assert 'event_picture/ercchy' in response .content
271
272
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
+
272
278
event_data = {
273
279
'audience' : [6 , 7 ],
274
280
'theme' : [3 ,4 ],
@@ -291,3 +297,4 @@ def test_edit_event_with_image(admin_user, admin_client, db):
291
297
292
298
response = admin_client .get (event .get_absolute_url ())
293
299
assert 'event_picture/ercchy' not in response .content
300
+
0 commit comments