X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/6280673f35e13e75e81c5b7821bd2a44a1831eab..357027375ff8867f42ca34bcbfb5a78b5b185fc3:/src/catalogue/tests/templatetags.py diff --git a/src/catalogue/tests/templatetags.py b/src/catalogue/tests/templatetags.py new file mode 100644 index 000000000..a66d604de --- /dev/null +++ b/src/catalogue/tests/templatetags.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from catalogue import models +from catalogue.templatetags import catalogue_tags +from catalogue.test_utils import * +from django.core.files.base import ContentFile + + +class BookDescTests(WLTestCase): + """ tests book_title template tag """ + + def setUp(self): + WLTestCase.setUp(self) + authors = PersonStub(("Common",), "Man"), PersonStub(("Jane",), "Doe") + + child_info = BookInfoStub(authors=authors, genre="Genre", epoch='Epoch', kind="Kind", + **info_args(u"Child")) + parent_info = BookInfoStub(authors=authors, genre="Genre", epoch='Epoch', kind="Kind", + parts=[child_info.url], + **info_args(u"Parent")) + + self.child = models.Book.from_text_and_meta(ContentFile(''), child_info) + models.Book.from_text_and_meta(ContentFile(''), parent_info) + self.child = models.Book.objects.get(pk=self.child.pk) + + def test_book_desc(self): + """ book description should return authors, ancestors, book """ + self.assertEqual(catalogue_tags.book_title(self.child), 'Jane Doe, Common Man, Parent, Child')