diff --git a/lostplaces/lostplaces_app/tests/models/test_place_image_model.py b/lostplaces/lostplaces_app/tests/models/test_place_image_model.py index c0231b2..8a1d137 100644 --- a/lostplaces/lostplaces_app/tests/models/test_place_image_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_place_image_model.py @@ -44,6 +44,11 @@ class TestPlaceImage(SubmittableTestCase, TestCase): 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( description='Im a description', 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): - # TODO path = self.object.filename.path self.object.delete() self.assertFalse(