Ejemplo n.º 1
0
    def test_chain(self):
        """
        """
        # Broad check
        arbiter = Arbiter([
            SourceCategoryRule(),
            SourceRule()
        ])
        source1 = Source.objects.get(name='villagevoice')
        source2 = Source.objects.get(name='fandango')
        movie_category = Category.objects.get(title='Movies')
        for event in Event.objects.all():
            ext_cat_objs = ExternalCategory.objects.filter(
                concrete_category=event.concrete_category)
            for ext_cat_obj in ext_cat_objs:
                concrete, abstracts = arbiter.apply_rules(event,
                                                          source1,
                                                          [ext_cat_obj])
                if concrete:
                    break

            self.assertEqual(concrete, [event.concrete_category])
            # Confirm that this does not compare a list of events to a
            # Manager
            # Tests for abstracts don't work yet.
            # self.assertEqual(abstracts, event.categories)
            source = Source.objects.get(id=2)
            concrete, abstracts = arbiter.apply_rules(event,
                                                       source2,
                                                       [])
            self.assertEqual(concrete, [movie_category])
Ejemplo n.º 2
0
    def test_chain(self):
        """
        """
        # Broad check
        arbiter = Arbiter([SourceCategoryRule(), SourceRule()])
        source1 = Source.objects.get(name='villagevoice')
        source2 = Source.objects.get(name='fandango')
        movie_category = Category.objects.get(title='Movies')
        for event in Event.objects.all():
            ext_cat_objs = ExternalCategory.objects.filter(
                concrete_category=event.concrete_category)
            for ext_cat_obj in ext_cat_objs:
                concrete, abstracts = arbiter.apply_rules(
                    event, source1, [ext_cat_obj])
                if concrete:
                    break

            self.assertEqual(concrete, [event.concrete_category])
            # Confirm that this does not compare a list of events to a
            # Manager
            # Tests for abstracts don't work yet.
            # self.assertEqual(abstracts, event.categories)
            source = Source.objects.get(id=2)
            concrete, abstracts = arbiter.apply_rules(event, source2, [])
            self.assertEqual(concrete, [movie_category])
Ejemplo n.º 3
0
 def test_concrete_filters(self):
     arbiter = Arbiter([SourceCategoryRule(), SourceRule()])
     source = Source.objects.get(name='villagevoice')
     xid_list = ['1134089', '1134052', '1134052']
     xids = ExternalCategory.objects.filter(xid__in=xid_list)
     for event in Event.objects.filter(concrete_category__id=28):
         concrete = arbiter.concrete_categories(event, source, xids)
         self.assertEqual(event.concrete_category, concrete)
Ejemplo n.º 4
0
 def test_concrete_filters(self):
     arbiter = Arbiter([
         SourceCategoryRule(),
         SourceRule()
     ])
     source = Source.objects.get(name='villagevoice')
     xid_list = ['1134089', '1134052', '1134052']
     xids = ExternalCategory.objects.filter(xid__in=xid_list)
     for event in Event.objects.filter(concrete_category__id=28):
         concrete = arbiter.concrete_categories(event, source, xids)
         self.assertEqual(event.concrete_category,concrete)