Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 5b51712

Browse files
committed
modify test test_edit_event_with_image to test if the old event picture is getting deleted
1 parent ec1290c commit 5b51712

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

web/tests/test_event_views.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import pytest
44
import StringIO
5+
import os
56

67
from py.path import local
78
from 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

Comments
 (0)