Fundraising in PDF.
[wolnelektury.git] / src / catalogue / tests / test_templatetags.py
1 # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Wolne Lektury. See NOTICE for more information.
3 #
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
8
9
10 class BookDescTests(WLTestCase):
11     """ tests book_title template tag """
12
13     def setUp(self):
14         WLTestCase.setUp(self)
15         authors = PersonStub(("Common",), "Man"), PersonStub(("Jane",), "Doe")
16
17         child_info = BookInfoStub(authors=authors, genre="Genre", epoch='Epoch', kind="Kind",
18                                   **info_args("Child"))
19         parent_info = BookInfoStub(authors=authors, genre="Genre", epoch='Epoch', kind="Kind",
20                                    parts=[child_info.url],
21                                    **info_args("Parent"))
22
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)
26
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')