diff --git a/ynr/apps/people/tests/test_person_models.py b/ynr/apps/people/tests/test_person_models.py index 9841219bc..9f081c6df 100644 --- a/ynr/apps/people/tests/test_person_models.py +++ b/ynr/apps/people/tests/test_person_models.py @@ -47,6 +47,42 @@ def test_get_display_image_url(self): person = Person.objects.get() self.assertEqual(person.get_display_image_url(), url) + def test_all_person_images_have_a_timestamp(self): + """ensure that all person images have a timestamp""" + person = PersonFactory(name=faker_factory.name()) + pi = PersonImage.objects.create_from_file( + filename=EXAMPLE_IMAGE_FILENAME, + new_filename="images/jowell-pilot.jpg", + defaults={ + "person": person, + "source": "Taken from Wikipedia", + "copyright": "example-license", + "user_notes": "A photo of Tessa Jowell", + }, + ) + self.assertIsNotNone(pi.created) + self.assertIsNotNone(pi.modified) + + def test_person_image_modified_timestamp(self): + """visit the person-view.html template and check the response for the modified timestamp""" + person = PersonFactory(name=faker_factory.name()) + pi = PersonImage.objects.create_from_file( + filename=EXAMPLE_IMAGE_FILENAME, + new_filename="images/jowell-pilot.jpg", + defaults={ + "person": person, + "source": "Taken from Wikipedia", + "copyright": "example-license", + "user_notes": "A photo of Tessa Jowell", + }, + ) + modified = pi.modified + response = self.app.get(f"/person/{person.id}", user=self.user) + self.assertIn( + f"This photo was uploaded on {modified.strftime('%-d %B %Y %H:%M')}.", + response.text, + ) + def test_get_alive_now(self): alive_person = PersonFactory(name=faker_factory.name()) PersonFactory(name=faker_factory.name(), death_date="2016-01-01")