Add test for `Child.birth_datetime()`

This commit is contained in:
Christopher C. Wells 2023-10-21 12:57:46 -07:00 committed by Christopher Charbonneau Wells
parent 43ab2694b4
commit 0f7c49b4f1
1 changed files with 18 additions and 0 deletions

View File

@ -64,6 +64,24 @@ class ChildTestCase(TestCase):
child.delete()
self.assertEqual(models.Child.count(), 1)
def test_child_birth_datetime(self):
birth_date = timezone.localdate()
models.Child.objects.create(
first_name="First", last_name="Last", birth_date=birth_date
)
self.assertEqual(models.Child.objects.last().birth_datetime(), birth_date)
birth_time = datetime.datetime.now().time()
models.Child.objects.create(
first_name="Second",
last_name="Last",
birth_date=birth_date,
birth_time=birth_time,
)
self.assertEqual(
models.Child.objects.last().birth_datetime(),
timezone.make_aware(datetime.datetime.combine(birth_date, birth_time)),
)
class DiaperChangeTestCase(TestCase):
def setUp(self):