Fixing PlaceImage tests

This commit is contained in:
Leonhard Strohmidel
2022-09-25 16:13:19 +02:00
parent 7a7c06882a
commit f06b6bdae9
3 changed files with 12 additions and 4 deletions

View File

@@ -42,21 +42,25 @@ class PlaceImageTestCase(ModelTestCase):
if not os.path.isdir(settings.MEDIA_ROOT):
os.mkdir(settings.MEDIA_ROOT)
images_dir = os.path.join(
settings.MEDIA_ROOT,
settings.RELATIVE_THUMBNAIL_PATH,
)
current_dir = os.path.dirname(os.path.abspath(__file__))
if not os.path.isfile(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_copy.jpeg')
os.path.join(images_dir, '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')
os.path.join(images_dir, 'im_a_image_changed.jpeg')
)
PlaceImage.objects.create(
description='Im a description',
filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'),
filename=os.path.join(images_dir, 'im_a_image_copy.jpeg'),
place=place,
submitted_when=timezone.now(),
submitted_by=user.explorer