def test_inverted_age_range_invalid(self): data = model_to_dict(self.study) data["min_age_years"] = 2 data["min_age_months"] = 0 data["min_age_days"] = 0 data["max_age_years"] = 1 data["max_age_months"] = 0 data["max_age_days"] = 0 form = StudyEditForm(data=data, instance=self.study, user=self.study_designer) self.assertIn(self.age_error_message, form.non_field_errors())
def test_age_range_validation_uses_30_day_month_definition(self): data = model_to_dict(self.study) data["min_age_years"] = 0 data["min_age_months"] = 11 data[ "min_age_days"] = 31 # Min age 361 days per usual definitions; 365.6 if month = 365/12 data["max_age_years"] = 1 data["max_age_months"] = 0 data["max_age_days"] = 0 form = StudyEditForm(data=data, instance=self.study, user=self.study_designer) self.assertNotIn(self.age_error_message, form.non_field_errors())