some new tests, some fixes in old ones
[wolnelektury.git] / apps / catalogue / tests / templatetags.py
1 # -*- coding: utf-8 -*-
2 from catalogue import models
3 from catalogue.templatetags import catalogue_tags
4 from catalogue.test_utils import *
5 from django.core.files.base import ContentFile
6
7
8 class BookDescTests(WLTestCase):
9     """ tests book_title template tag """
10
11     def setUp(self):
12         WLTestCase.setUp(self)
13         author = PersonStub(("Common",), "Man")
14
15         child_info = BookInfoStub(author=author, genre="Genre", epoch='Epoch', kind="Kind",
16                                    **info_args(u"Child"))
17         parent_info = BookInfoStub(author=author, genre="Genre", epoch='Epoch', kind="Kind",
18                                    parts=[child_info.url],
19                                    **info_args(u"Parent"))
20
21         self.child = models.Book.from_text_and_meta(ContentFile('<utwor/>'), child_info)
22         models.Book.from_text_and_meta(ContentFile('<utwor/>'), parent_info)
23         self.child = models.Book.objects.get(pk=self.child.pk)
24
25     def test_book_desc(self):
26         """ book description should return authors, ancestors, book """
27         self.assertEqual(catalogue_tags.book_title(self.child), 'Common Man, Parent, Child')