Example #1
0
    def test_survey_with_required_data(self):
        self.assertFalse(has_required_data(self.survey, self.subject))

        Fact.objects.create(survey=self.survey, subject=self.subject,
                desired_fact=self.desired_fact, data='1', created_by=self.user,
                updated_by=self.user)

        self.assertTrue(has_required_data(self.survey, self.subject))
Example #2
0
    def test_survey_with_mixed_data(self):
        DesiredFact.objects.create(code='code2',
                label='enter data', data_type='T',
                required=False, content_type=self.content_type)
        self.assertFalse(has_required_data(self.survey, self.subject))

        Fact.objects.create(survey=self.survey, subject=self.subject,
                desired_fact=self.desired_fact, data='1', created_by=self.user,
                updated_by=self.user)

        self.assertTrue(has_required_data(self.survey, self.subject))
Example #3
0
 def test_survey_with_no_desired_facts(self):
     self.desired_fact.delete()
     self.assertTrue(has_required_data(self.survey, self.subject))
Example #4
0
 def test_survey_with_non_required_data(self):
     self.desired_fact.required = False
     self.desired_fact.save()
     self.assertTrue(has_required_data(self.survey, self.subject))
Example #5
0
 def form_valid(self, form):
     if models.has_required_data(self.survey, self.subject):
         redirect_url = reverse('survey-detail', kwargs={'pk': self.survey.id})
         return HttpResponseRedirect(redirect_url)
     else:
         return self.form_invalid(form)