diff --git a/core/tests/tests_forms.py b/core/tests/tests_forms.py index 26c949a6..4c8ba7b6 100644 --- a/core/tests/tests_forms.py +++ b/core/tests/tests_forms.py @@ -87,29 +87,49 @@ class InitialValuesTestCase(FormsTestCaseBase): last_name='Two', birth_date=timezone.localdate() ) + child_three = models.Child.objects.create( + first_name='Child', + last_name='Three', + birth_date=timezone.localdate() + ) + start_time = timezone.localtime() - timezone.timedelta(hours=4) + end_time = timezone.localtime() - timezone.timedelta(hours=3, minutes=30) f_one = models.Feeding.objects.create( child=self.child, - start=timezone.localtime() - timezone.timedelta(hours=4), - end=timezone.localtime() - timezone.timedelta(hours=3, minutes=30), + start=start_time, + end=end_time, type='breast milk', method='left breast' ) f_two = models.Feeding.objects.create( child=child_two, - start=timezone.localtime() - timezone.timedelta(hours=4), - end=timezone.localtime() - timezone.timedelta(hours=3, minutes=30), + start=start_time, + end=end_time, type='formula', method='bottle' ) + f_three = models.Feeding.objects.create( + child=child_three, + start=start_time, + end=end_time, + type='fortified breast milk', + method='bottle' + ) page = self.c.get('/feedings/add/') self.assertTrue('type' not in page.context['form'].initial) page = self.c.get('/feedings/add/?child={}'.format(self.child.slug)) self.assertEqual(page.context['form'].initial['type'], f_one.type) + self.assertFalse('method' in page.context['form'].initial) page = self.c.get('/feedings/add/?child={}'.format(child_two.slug)) self.assertEqual(page.context['form'].initial['type'], f_two.type) + self.assertEqual(page.context['form'].initial['method'], f_two.method) + + page = self.c.get('/feedings/add/?child={}'.format(child_three.slug)) + self.assertEqual(page.context['form'].initial['type'], f_three.type) + self.assertEqual(page.context['form'].initial['method'], f_three.method) def test_timer_set(self): self.timer.stop()