class TagRelatedTagsTests(WLTestCase):
""" tests the /katalog/category/tag/ page for related tags """
def setUp(self):
WLTestCase.setUp(self)
class TagRelatedTagsTests(WLTestCase):
""" tests the /katalog/category/tag/ page for related tags """
def setUp(self):
WLTestCase.setUp(self)
author = PersonStub(("Common",), "Man")
gchild_info = BookInfoStub(author=author, genre="GchildGenre", epoch='Epoch', kind="Kind",
author = PersonStub(("Common",), "Man")
gchild_info = BookInfoStub(author=author, genre="GchildGenre", epoch='Epoch', kind="Kind",
self.assertFalse('Kind' in [tag.name for tag in cats['kind']],
'filtering tag wrongly included in related')
cats = self.client.get('/katalog/motyw/theme/').context['categories']
self.assertFalse('Theme' in [tag.name for tag in cats['theme']],
'filtering theme wrongly included in related')
self.assertFalse('Kind' in [tag.name for tag in cats['kind']],
'filtering tag wrongly included in related')
cats = self.client.get('/katalog/motyw/theme/').context['categories']
self.assertFalse('Theme' in [tag.name for tag in cats['theme']],
'filtering theme wrongly included in related')
def test_parent_tag_once(self):
""" if parent and descendants have a common tag, count it only once """
def test_parent_tag_once(self):
""" if parent and descendants have a common tag, count it only once """
def test_delete_objects(self):
""" there should be no related tags left after deleting some objects """
def test_delete_objects(self):
""" there should be no related tags left after deleting some objects """
- cats = self.client.get('/katalog/lektura/book/').context['categories']
- self.assertEqual(cats, {})
+ self.assertEqual(len(self.book.related_info()['tags']), 0)
+ self.assertEqual(len(self.book.related_themes()), 0)
self.assertEqual(models.Tag.intermediary_table_model.objects.all().count(), 0,
"orphaned TagRelation objects left")
self.assertEqual(models.Tag.intermediary_table_model.objects.all().count(), 0,
"orphaned TagRelation objects left")
for category in 'author', 'kind', 'genre', 'epoch':
for category in 'author', 'kind', 'genre', 'epoch':
def test_qualified_url(self):
models.Book.from_text_and_meta(ContentFile(self.book_text), self.book_info)
def test_qualified_url(self):
models.Book.from_text_and_meta(ContentFile(self.book_text), self.book_info)
- self.assertEqual([tag.name for tag in context['categories']['author']],
- ['Common Man'])
- self.assertEqual([tag.name for tag in context['categories']['kind']],
- ['Kind'])
- self.assertEqual([(tag.name, tag.count) for tag in context['book_themes']],
+ self.assertEqual([t['slug'] for t in related_info['tags']['author']],
+ ['common-man'])
+ self.assertEqual([t['slug'] for t in related_info['tags']['kind']],
+ ['kind'])
+ self.assertEqual([(tag.name, tag.count) for tag in related_themes],
[('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])
[('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])
[('Jim Lazy', 1), ('Common Man', 1)])
[('Jim Lazy', 1), ('Common Man', 1)])
[('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])
[('ChildTheme', 1), ('ParentTheme', 1), ('Theme', 2)])