Skip to content

Commit

Permalink
Test migration and template for PersonImage timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Jul 2, 2024
1 parent ad76069 commit 7728dff
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ynr/apps/people/tests/test_person_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7728dff

Please sign in to comment.