Testing Placeimage file change

This commit is contained in:
reverend 2020-09-12 08:48:53 +02:00
parent 64c0c5f8e6
commit 4ee7373b3f

View File

@ -44,6 +44,11 @@ class TestPlaceImage(SubmittableTestCase, TestCase):
os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg') os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg')
) )
shutil.copyfile(
os.path.join(current_dir, 'im_a_image.jpeg'),
os.path.join(settings.MEDIA_ROOT, 'im_a_image_changed.jpeg')
)
PlaceImage.objects.create( PlaceImage.objects.create(
description='Im a description', description='Im a description',
filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'), filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'),
@ -82,8 +87,16 @@ class TestPlaceImage(SubmittableTestCase, TestCase):
) )
) )
def test_change_filename(self):
path = self.object.filename.path
self.object.filename = os.path.join(settings.MEDIA_ROOT, 'im_a_image_changed.jpeg')
self.object.save()
self.assertFalse(
os.path.isfile(path),
msg='Expecting the old file of an place_image to be deleteed when an place_image file is changed'
)
def test_deletion(self): def test_deletion(self):
# TODO
path = self.object.filename.path path = self.object.filename.path
self.object.delete() self.object.delete()
self.assertFalse( self.assertFalse(