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])
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])
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)
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)