示例#1
0
 def test_multiple_filters_returned_from_querydict(self):
     search_term = "Amet"
     afrikaans = LanguageFactory(title="Afrikaans")
     afrikaans.save()
     thailand = CountryFactory(title="Country")
     thailand.save()
     scotus = TopicFactory(title="SCOTUS")
     scotus.save()
     querydict = QueryDict(
         'search={}&language={}&topic={}&country={}'.format(
             search_term, afrikaans.id, scotus.id, thailand.id))
     filters = self.directory.filters_from_querydict(querydict)
     self.assertEqual(filters['title__icontains'], search_term)
     self.assertEqual(filters['topics'], scotus)
     self.assertEqual(filters['countries'], thailand)
     self.assertEqual(filters['languages'], afrikaans)
示例#2
0
    def setUp(self):
        self.directory = DirectoryPageFactory()
        # set up topics
        pf = TopicFactory(title='Press Freedom')
        irs = TopicFactory(title='IRS')
        pf.save()
        irs.save()
        # set up instances that are children of the directory and have those topics
        self.pf_instance = DirectoryEntryFactory(parent=self.directory)
        self.pf_instance.topics.add(pf)
        self.pf_instance.save()

        self.irs_instance = DirectoryEntryFactory(parent=self.directory)
        self.irs_instance.topics.add(irs)
        self.irs_instance.save()
        self.topic_filter = {'topics': pf}
示例#3
0
    def setUp(self):
        self.directory = DirectoryPageFactory()
        # set up languages
        spanish = LanguageFactory(title='Spanish')
        chinese = LanguageFactory(title='Chinese')
        spanish.save()
        chinese.save()
        # set up countries
        mexico = CountryFactory(title='Mexico')
        azerbaijan = CountryFactory(title='Azerbaijan')
        mexico.save()
        azerbaijan.save()
        # set up topics
        pf = TopicFactory(title='Press Freedom')
        irs = TopicFactory(title='IRS')
        pf.save()
        irs.save()
        # set up instances that are children of the directory and have multiple categories
        self.sp_mx_instance = DirectoryEntryFactory(parent=self.directory)
        self.sp_mx_instance.languages.add(spanish)
        self.sp_mx_instance.countries.add(mexico)
        self.sp_mx_instance.save()

        self.az_pf_instance = DirectoryEntryFactory(parent=self.directory)
        self.az_pf_instance.countries.add(azerbaijan)
        self.az_pf_instance.topics.add(pf)
        self.az_pf_instance.save()

        self.other_instance = DirectoryEntryFactory(parent=self.directory)
        self.other_instance.languages.add(spanish)
        self.other_instance.topics.add(pf)
        self.other_instance.save()

        # filters
        self.lang_country_filter = {
            'languages': spanish,
            'countries': mexico
        }

        self.country_topic_filter = {
            'countries': azerbaijan,
            'topics': pf
        }
示例#4
0
 def test_correct_topic_returned_from_querydict(self):
     sports = TopicFactory(title="sports")
     sports.save()
     querydict = QueryDict('topic={}'.format(sports.id))
     filters = self.directory.filters_from_querydict(querydict)
     self.assertEqual(filters['topics'], sports)