def test_form_with_invalid_contact_person(self): data = self.form_data data.update({'contact_person': ''}) form = WeeklySessionAdminForm(data=data) self.assertFalse(form.is_valid()) self.assertEquals(len(form.errors), 1) self.assertIn('contact_person', form.errors.keys()) self.assertIn(['This field is required.'], form.errors.values())
def test_invalid_time(self): data = self.form_data data.update({'time': '25:00'}) form = WeeklySessionAdminForm(data=data) self.assertFalse(form.is_valid()) self.assertIn('Invalid time format', str(form.errors['time']))
def test_form_valid(self): form = WeeklySessionAdminForm(data=self.form_data) self.assertTrue(form.is_valid())