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

Commit fea432b

Browse files
committed
Merge pull request #321 from Konviser/master
modify test test_edit_event_with_image to test if the old event picture is getting deleted
2 parents 4bdcc97 + 47b5812 commit fea432b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

web/tests/test_event_views.py

Lines changed: 9 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
@@ -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

Comments
 (0)