def test_good_data_validates(self): minimal_data = { 'date_collected': '2016-01-01', 'achieved': '30', 'indicator': self.indicator.id, 'program': self.program.id, 'rationale': 'this is a rationale' } form = ResultForm(minimal_data, **self.form_kwargs) self.assertTrue(form.is_valid(), "errors {0}".format(form.errors)) new_result = form.save() self.assertIsNotNone(new_result.id) db_result = Result.objects.get(pk=new_result.id) self.assertEqual(db_result.date_collected, datetime.date(2016, 1, 1)) self.assertEqual(db_result.achieved, 30)
def test_good_data_with_evidence_validates(self): minimal_data = { 'date_collected': '2016-03-31', 'achieved': '30', 'indicator': self.indicator.id, 'program': self.program.id, 'record_name': 'new record', 'evidence_url': 'http://google.com', 'rationale': 'this is a rationale' } form = ResultForm(minimal_data, **self.form_kwargs) self.assertTrue(form.is_valid(), "errors {0}".format(form.errors)) new_result = form.save() self.assertIsNotNone(new_result.id) db_result = Result.objects.get(pk=new_result.id) self.assertEqual(db_result.record_name, 'new record')