Add test for child without last name

This commit is contained in:
Christopher C. Wells 2022-05-25 20:35:45 -07:00 committed by Christopher Charbonneau Wells
parent c91b556739
commit 00d04f1464
1 changed files with 10 additions and 0 deletions

View File

@ -39,6 +39,16 @@ class ChildTestCase(TestCase):
self.assertEqual(child.name(), "First Last") self.assertEqual(child.name(), "First Last")
self.assertEqual(child.name(reverse=True), "Last, First") self.assertEqual(child.name(reverse=True), "Last, First")
def test_child_create_without_last_name(self):
child = models.Child.objects.create(
first_name="Nolastname", birth_date=timezone.localdate()
)
self.assertEqual(child, models.Child.objects.get(first_name="Nolastname"))
self.assertEqual(child.slug, "nolastname")
self.assertEqual(str(child), "Nolastname")
self.assertEqual(child.name(), "Nolastname")
self.assertEqual(child.name(reverse=True), "Nolastname")
def test_child_count(self): def test_child_count(self):
self.assertEqual(models.Child.count(), 0) self.assertEqual(models.Child.count(), 0)
models.Child.objects.create( models.Child.objects.create(