def test_maternal_obsterical_history_children_died_b4_5yrs_valid(self):
     self.data = {
         'report_datetime': timezone.now(),
         'maternal_visit': self.maternal_visit.id,
         'prev_pregnancies': 1,
         'pregs_24wks_or_more': 1,
         'lost_before_24wks': 0,
         'lost_after_24wks': 0,
         'live_children': 1,
         'children_died_b4_5yrs': 1
     }
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_maternal_obsterical_history_children_died_b4_5yrs_valid(self):
     self.data = {
         'report_datetime': timezone.now(),
         'maternal_visit': self.maternal_visit.id,
         'prev_pregnancies': 1,
         'pregs_24wks_or_more': 1,
         'lost_before_24wks': 0,
         'lost_after_24wks': 0,
         'live_children': 1,
         'children_died_b4_5yrs': 1
     }
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_lost_before_24wks_grt_prev_preg(self):
     self.data['prev_pregnancies'] = 2
     self.data['lost_before_24wks'] = 3
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertIn(
         "Number of pregnancies lost before 24 weeks cannot be greater than previous pregnancies.",
         mob.errors.get('__all__'))
 def test_preg24wks_grt_prev_preg(self):
     self.data['prev_pregnancies'] = 2
     self.data['pregs_24wks_or_more'] = 3
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertIn(
         "Number of pregnancies carried at least 24 weeks cannot be greater than previous pregnancies.",
         mob.errors.get('__all__'))
 def test_prev_pregnancies_zero_1(self):
     self.data['prev_pregnancies'] = 1
     self.data['pregs_24wks_or_more'] = 0
     self.data['lost_before_24wks'] = 0
     self.data['lost_after_24wks'] = 0
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertIn(
         "You indicated previous pregancies were 1. Number of pregnancies at or after 24 weeks,"
         "number of living children,number of children died after 5 year CANNOT all be zero.",
         mob.errors.get('__all__'))
 def test_lost_after_24wks_grt_prev_preg(self):
     self.data['prev_pregnancies'] = 2
     self.data['pregs_24wks_or_more'] = 1
     self.data['lost_before_24wks'] = 1
     self.data['lost_after_24wks'] = 3
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertIn(
         "Number of pregnancies lost at or after 24 weeks gestation cannot be greater "
         "than number of previous pregnancies or number of pregnancies at least 24 weeks.",
         mob.errors.get('__all__'))
 def test_pregs_24wks_or_more_plus_lost_before_24wks_grt_prev_pregnancies(
         self):
     self.data['prev_pregnancies'] = 3
     self.data['pregs_24wks_or_more'] = 1
     self.data['lost_before_24wks'] = 1
     self.data['lost_after_24wks'] = 1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertIn(
         "The sum of Number of pregnancies at least 24 weeks and "
         "number of pregnancies lost before 24 weeks gestation. must be equal to "
         "number of previous pregnancies for this participant.",
         mob.errors.get('__all__'))
 def test_maternal_obsterical_history_children_died_b4_5yrs_invalid(self):
     self.data['children_died_b4_5yrs'] = -1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertFalse(mob.is_valid())
 def test_maternal_obsterical_history_form_valid(self):
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_zero_previous_pregnancies(self):
     self.data['prev_pregnancies'] = -1
     self.data['pregs_24wks_or_more'] = 1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertFalse(mob.is_valid())
 def test_maternal_obsterical_history_pregs_24wks_or_more_valid(self):
     self.data['pregs_24wks_or_more'] = 1
     self.data['lost_after_24wks'] = 1
     self.data['children_died_b4_5yrs'] = 1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_maternal_obsterical_history_live_children_valid(self):
     self.data['live_children'] = 2
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_maternal_obsterical_history_children_died_b4_5yrs_invalid(self):
     self.data['children_died_b4_5yrs'] = -1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertFalse(mob.is_valid())
 def test_maternal_obsterical_history_form_valid(self):
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_maternal_obsterical_history_live_children_valid(self):
     self.data['live_children'] = 2
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_maternal_obsterical_history_pregs_24wks_or_more_valid(self):
     self.data['pregs_24wks_or_more'] = 1
     self.data['lost_after_24wks'] = 1
     self.data['children_died_b4_5yrs'] = 1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertTrue(mob.is_valid())
 def test_zero_previous_pregnancies(self):
     self.data['prev_pregnancies'] = -1
     self.data['pregs_24wks_or_more'] = 1
     mob = MaternalObstericalHistoryForm(data=self.data)
     self.assertFalse(mob.is_valid())