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