mirror of https://github.com/snachodog/mybuddy.git
Tests for initial feeding methods (#127)
This commit is contained in:
parent
4581722e0b
commit
dfd89ae339
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue