1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from catalogue import models
5 from catalogue.templatetags import catalogue_tags
6 from catalogue.test_utils import *
7 from django.core.files.base import ContentFile
10 class BookDescTests(WLTestCase):
11 """ tests book_title template tag """
14 WLTestCase.setUp(self)
15 authors = PersonStub(("Common",), "Man"), PersonStub(("Jane",), "Doe")
17 child_info = BookInfoStub(authors=authors, genre="Genre", epoch='Epoch', kind="Kind",
19 parent_info = BookInfoStub(authors=authors, genre="Genre", epoch='Epoch', kind="Kind",
20 parts=[child_info.url],
21 **info_args("Parent"))
23 self.child = models.Book.from_text_and_meta(ContentFile('<utwor/>'), child_info)
24 models.Book.from_text_and_meta(ContentFile('<utwor/>'), parent_info)
25 self.child = models.Book.objects.get(pk=self.child.pk)
27 def test_book_desc(self):
28 """ book description should return authors, ancestors, book """
29 self.assertEqual(catalogue_tags.book_title(self.child), 'Jane Doe, Common Man, Parent, Child')