From f06b6bdae94234e2961381748b1919b1a9fbdd8d Mon Sep 17 00:00:00 2001 From: Leonhard Strohmidel Date: Sun, 25 Sep 2022 16:13:19 +0200 Subject: [PATCH] Fixing PlaceImage tests --- .../lostplaces/templates/partials/place_teaser.html | 2 +- .../lostplaces/tests/models/test_place_image_model.py | 10 +++++++--- .../lostplaces/tests/views/test_base_views.py | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/django_lostplaces/lostplaces/templates/partials/place_teaser.html b/django_lostplaces/lostplaces/templates/partials/place_teaser.html index 436916c..a0c1c8b 100644 --- a/django_lostplaces/lostplaces/templates/partials/place_teaser.html +++ b/django_lostplaces/lostplaces/templates/partials/place_teaser.html @@ -14,7 +14,7 @@
-

{{place.name|truncatechars:19}}

+

{{place.name}}

{{place.location|truncatechars:25}}

diff --git a/django_lostplaces/lostplaces/tests/models/test_place_image_model.py b/django_lostplaces/lostplaces/tests/models/test_place_image_model.py index 0bbfa84..59a0e56 100644 --- a/django_lostplaces/lostplaces/tests/models/test_place_image_model.py +++ b/django_lostplaces/lostplaces/tests/models/test_place_image_model.py @@ -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 diff --git a/django_lostplaces/lostplaces/tests/views/test_base_views.py b/django_lostplaces/lostplaces/tests/views/test_base_views.py index 169f217..f26ea9e 100644 --- a/django_lostplaces/lostplaces/tests/views/test_base_views.py +++ b/django_lostplaces/lostplaces/tests/views/test_base_views.py @@ -46,6 +46,10 @@ class TestIsAuthenticated(ViewTestCase): self.assertHttpRedirect(response, '?'.join([str(reverse_lazy('login')), 'next=/'])) self.assertTrue(len(messages) > 0) + self.assertTrue( + _('Please login to proceed') in response.content.decode(), + msg='Expecting a message to tell the user to login' + ) class TestIsPlaceSubmitterMixin(TestCase):