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)) )
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))
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))
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) )
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) )
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))
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) )
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)
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)))
def test_get_subjects_no_subjects(self): self.assertEquals([], list(get_subjects(self.survey, self.content_type)))
def test_get_subjects_no_subjects(self): self.assertEquals( [], list(get_subjects(self.survey, self.content_type)) )