def test_assets_match_at_least_one_tag_of_all_active_tag_categories_of_passed_tags(self): """ project1 has assets 1,2,5,6 project1 related to masteruis 1,2 masteruis 1,2 give tagcategories 2,3 pass tag2 and tag3 that are in categories 2 and 3 so, assets returned must have a tag in category 2 and 3 so it should return assets with tag2 and tag3: = no assets asset2 matches category 2 but not 3 """ recs = filter_recs_for_tags(self.project1, [self.tag2.id, self.tag3.id], self.english) self.assertEqual([], recs)
def test_only_assets_with_correct_tag_categories(self): """ project 1 has assets 1,2,5,6 project1 related to masterui1, masterui2, therefore tagcat2, tagcat3 are the active cats, therefore pass tag 1, 2 that are in categories 1 and 2 so, assets returned must have a tag in category 2 so, it should return assets with tag2: = asset2 """ recs = filter_recs_for_tags(self.project1, [self.tag1.id, self.tag2.id], self.english) self.assertNotIn(self.asset1, recs) self.assertIn(self.asset2, recs) self.assertNotIn(self.asset3, recs) self.assertNotIn(self.asset4, recs) self.assertNotIn(self.asset5, recs)
def test_no_assets_from_tags_from_inactive_masteruis(self): """ project1 has assets 1,2,5,6 project1 related to masteruis 1,2 masterui2 now inactive so we only care about tagcategory 2 pass tag 3 that's in category 3 if masterui2 were active, we'd care about category 3 assets returned would have had to have a tag in category 2 and 3 but since masterui2 is inactive assets only have to have tag in cat 2 """ self.masterui2.active = False self.masterui2.save() recs = filter_recs_for_tags(self.project1, [self.tag3.id], self.english) self.assertIn(self.asset2, recs) self.masterui2.active = True self.masterui2.save()
def test_only_assets_in_desired_language(self): recs = filter_recs_for_tags(self.project2, [self.tag1.id], self.spanish) self.assertIn(self.asset3, recs) # spanish language asset self.assertNotIn(self.asset4, recs) # english
def test_no_assets_from_wrong_projects(self): recs = filter_recs_for_tags(self.project1, [self.tag1.id, self.tag2.id], self.english) self.assertNotIn(self.asset4, recs)
def test_no_assets_too_short_audiolength(self): recs = filter_recs_for_tags(self.project1, [self.tag1.id, self.tag2.id], self.english) self.assertNotIn(self.asset6, recs)