Example #1
0
 def test_get_subjects(self):
     "with no where clause, should return all subjects with facts"
     self._save_fact('01')
     self.assertEquals(
             [self.subject],
             list(get_subjects(self.survey, self.content_type))
         )
Example #2
0
    def test_get_subjects_where_no_match(self):
        "empty queryset should be returned if no matches"
        self._save_fact('01')
        subjects = get_subjects(self.survey,
                                self.content_type,
                                desired_facts=self.desired_fact,
                                value='02')

        self.assertEquals([], list(subjects))
Example #3
0
    def test_get_subjects_where(self):
        "only expect facts with data that matches the where clause"
        self._save_fact('01')
        subjects = get_subjects(self.survey,
                                self.content_type,
                                desired_facts=self.desired_fact,
                                value='01')

        self.assertEquals([self.subject], list(subjects))
Example #4
0
    def test_get_subjects_where_no_match(self):
        "empty queryset should be returned if no matches"
        self._save_fact('01')
        subjects = get_subjects(self.survey, self.content_type,
                desired_facts=self.desired_fact, value='02')

        self.assertEquals(
                [],
                list(subjects)
            )
Example #5
0
    def test_get_subjects_where(self):
        "only expect facts with data that matches the where clause"
        self._save_fact('01')
        subjects = get_subjects(self.survey, self.content_type,
                desired_facts=self.desired_fact, value='01')

        self.assertEquals(
                [self.subject],
                list(subjects)
            )
Example #6
0
    def test_get_subjects_where_multi_match(self):
        "Should get all matching subjects"
        self._save_fact('01', subject=self.subject)
        self._save_fact('01', subject=self.subject2)

        subjects = get_subjects(self.survey,
                                self.content_type,
                                desired_facts=self.desired_fact,
                                value='01')

        self.assertEquals(set([self.subject2, self.subject]), set(subjects))
Example #7
0
    def test_get_subjects_where_multi_match(self):
        "Should get all matching subjects"
        self._save_fact('01', subject=self.subject)
        self._save_fact('01', subject=self.subject2)

        subjects = get_subjects(self.survey, self.content_type,
                desired_facts=self.desired_fact, value='01')

        self.assertEquals(
                set([self.subject2, self.subject]),
                set(subjects)
            )
Example #8
0
    def test_facts_for_different_survey_not_counted(self):
        "must discriminate by survey"
        # associate self.subject with self.survey
        self._save_fact('01', subject=self.subject, survey=self.survey)

        # associate self.subject2 with a different survey
        survey2 = Survey.objects.create(name='other', project=self.project)
        self._save_fact('01', subject=self.subject2, survey=survey2)

        subjects = get_subjects(self.survey, self.content_type,
                desired_facts=self.desired_fact, value='01')

        self.assertTrue(self.subject in subjects)
        self.assertFalse(self.subject2 in subjects)
Example #9
0
    def test_facts_for_different_survey_not_counted(self):
        "must discriminate by survey"
        # associate self.subject with self.survey
        self._save_fact('01', subject=self.subject, survey=self.survey)

        # associate self.subject2 with a different survey
        survey2 = Survey.objects.create(name='other', project=self.project)
        self._save_fact('01', subject=self.subject2, survey=survey2)

        subjects = get_subjects(self.survey,
                                self.content_type,
                                desired_facts=self.desired_fact,
                                value='01')

        self.assertTrue(self.subject in subjects)
        self.assertFalse(self.subject2 in subjects)
Example #10
0
 def test_get_subjects(self):
     "with no where clause, should return all subjects with facts"
     self._save_fact('01')
     self.assertEquals([self.subject],
                       list(get_subjects(self.survey, self.content_type)))
Example #11
0
 def test_get_subjects_no_subjects(self):
     self.assertEquals([], list(get_subjects(self.survey,
                                             self.content_type)))
Example #12
0
 def test_get_subjects_no_subjects(self):
     self.assertEquals(
             [],
             list(get_subjects(self.survey, self.content_type))
         )