def test_delivery_date_1(self):
     """Delivery date is cannot be greater than reportdate"""
     self.data['report_datetime'] = timezone.now() - timezone.timedelta(days=1)
     self.data['delivery_datetime'] = timezone.now()
     form = MaternalLabourDelForm(data=self.data)
     self.assertIn('Delivery date cannot be greater than the report date. '
                   'Please correct.', form.errors.get('__all__'))
 def test_temp_3(self):
     """Temperature cannot be above 37.2"""
     self.data['has_temp'] = YES
     self.data['labour_max_temp'] = 40
     form = MaternalLabourDelForm(data=self.data)
     self.assertFalse(form.is_valid())
 def test_temp_2(self):
     self.data['labour_max_temp'] = 37
     form = MaternalLabourDelForm(data=self.data)
     errors = ''.join(form.errors.get('__all__'))
     self.assertIn("You have indicated that maximum temperature is not known. "
                   "You CANNOT provide the maximum temperature", errors)
 def test_temp_1(self):
     self.data['has_temp'] = YES
     form = MaternalLabourDelForm(data=self.data)
     self.assertIn("You have indicated that maximum temperature at delivery is known. "
                   "Please provide the maximum temperature.", form.errors.get('__all__'))
 def test_infants_to_register_3(self):
     '''Infant to register cannot be zero or less'''
     self.data['live_infants_to_register'] = -1
     form = MaternalLabourDelForm(data=self.data)
     self.assertIn('Number of live infants to register may not be less than or equal to 0!.',
                   form.errors.get('__all__'))
 def test_infants_to_register_2(self):
     '''Cannot register more than 1 infant.'''
     self.data['live_infants_to_register'] = 3
     form = MaternalLabourDelForm(data=self.data)
     self.assertIn('Only one infant per mother can be registered to the study.', form.errors.get('__all__'))
 def test_infants_to_register_1(self):
     form = MaternalLabourDelForm(data=self.data)
     self.assertTrue(form.is_valid())
 def test_deliverydate_vs_postpartum_days(self):
     self.data['delivery_datetime'] = timezone.now() - timezone.timedelta(days=1)
     form = MaternalLabourDelForm(data=self.data)
     self.assertIn('Delivery date does not correspond with the number of days post-partum as '
                   'reported at Postnatal Enrollment. Using \'{}\' days post-partum. Please correct'
                   .format(self.postnatal_enrollment.postpartum_days), form.errors.get('__all__'))
 def test_temp_5(self):
     self.data['has_temp'] = YES
     self.data['labour_max_temp'] = 36.8
     form = MaternalLabourDelForm(data=self.data)
     self.assertTrue(form.is_valid())
 def test_temp_4(self):
     form = MaternalLabourDelForm(data=self.data)
     self.assertTrue(form.is_valid())