Update model tests for timer-child relationship changes

This commit is contained in:
Christopher C. Wells 2020-01-29 12:00:25 -08:00 committed by Christopher Charbonneau Wells
parent 3eb0e336c6
commit 107257cc34
1 changed files with 24 additions and 1 deletions

View File

@ -23,6 +23,23 @@ 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_count(self):
self.assertEqual(models.Child.count(), 0)
models.Child.objects.create(
first_name='First 1',
last_name='Last 1',
birth_date=timezone.localdate()
)
self.assertEqual(models.Child.count(), 1)
child = models.Child.objects.create(
first_name='First 2',
last_name='Last 2',
birth_date=timezone.localdate()
)
self.assertEqual(models.Child.count(), 2)
child.delete()
self.assertEqual(models.Child.count(), 1)
class DiaperChangeTestCase(TestCase): class DiaperChangeTestCase(TestCase):
def setUp(self): def setUp(self):
@ -149,10 +166,16 @@ class TemperatureTestCase(TestCase):
class TimerTestCase(TestCase): class TimerTestCase(TestCase):
def setUp(self): def setUp(self):
call_command('migrate', verbosity=0) call_command('migrate', verbosity=0)
child = models.Child.objects.create(
first_name='First',
last_name='Last',
birth_date=timezone.localdate()
)
self.named = models.Timer.objects.create( self.named = models.Timer.objects.create(
name='Named', name='Named',
end=timezone.localtime(), end=timezone.localtime(),
user=User.objects.first() user=User.objects.first(),
child=child
) )
self.unnamed = models.Timer.objects.create( self.unnamed = models.Timer.objects.create(
end=timezone.localtime(), end=timezone.localtime(),