Made the test more descriptive and changed the function so we do not have to change other tests

This commit is contained in:
Wesley van Lee 2019-03-14 18:32:29 +01:00
parent e389a78e54
commit 50b187b757
3 changed files with 11 additions and 5 deletions

View file

@ -157,9 +157,15 @@ class TestInspectView(TestCase, WagtailTestUtils):
response = self.get(100)
self.assertEqual(response.status_code, 404)
def test_label_display(self):
def test_short_description_is_used_as_field_label(self):
"""
A custom field has been added to the inspect view's `inspect_view_fields` and since
this field has a `short_description` we expect it to be used as the field's label,
and not use the name of the function.
"""
response = self.client.get('/admin/modeladmintest/author/inspect/1/')
self.assertContains(response, 'Birth information')
self.assertNotContains(response, 'author_birth_string')
class TestEditView(TestCase, WagtailTestUtils):

View file

@ -222,11 +222,11 @@ class TestInspectView(TestCase, WagtailTestUtils):
def test_author_name_present(self):
"""
The author name should appear three times. Once in the header, once
in the name field and once more in the birth string
The author name should appear twice. Once in the header, and once
more in the field listing
"""
response = self.get_for_author(1)
self.assertContains(response, 'J. R. R. Tolkien', 3)
self.assertContains(response, 'J. R. R. Tolkien', 2)
def test_author_dob_not_present(self):
"""

View file

@ -10,7 +10,7 @@ class Author(models.Model):
date_of_birth = models.DateField()
def author_birth_string(self):
return '{} was born in pallet town'.format(self.name)
return 'This author was born in pallet town'
author_birth_string.short_description = "Birth information"