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.
4 from catalogue import models
5 from catalogue.test_utils import BookInfoStub, PersonStub, WLTestCase, info_args
6 from django.core.files.base import ContentFile
9 class VisitTest(WLTestCase):
10 """Simply create some objects and visit some views."""
13 WLTestCase.setUp(self)
14 author = PersonStub(("Jane",), "Doe")
15 book_info = BookInfoStub(author=author, genre="Sielanka",
16 epoch='Epoch', kind="Kind", **info_args("A book"))
17 self.book = models.Book.from_text_and_meta(ContentFile('''
22 <motyw id="m1">Sielanka</motyw>
29 self.collection = models.Collection.objects.create(
30 title='Biblioteczka Boya', slug='boy', book_slugs='a-book')
32 def test_visit_urls(self):
33 """ book description should return authors, ancestors, book """
41 'lektura/a-book.html',
42 'lektura/a-book/motyw/sielanka/',
47 # 'autor/jane-doe/gatunek/genre/',
48 # 'autor/jane-doe/gatunek/genre/motyw/sielanka/',
51 'lektury/nonexistent/', # Nonexistent Collection.
52 'lektura/nonexistent/', # Nonexistent Book.
53 'lektura/nonexistent.html', # Nonexistent Book's HTML.
54 'lektura/nonexistent/motyw/sielanka/', # Nonexistent Book's theme.
55 'lektura/a-book/motyw/nonexistent/', # Nonexistent theme in a Book.
56 'autor/nonexistent/', # Nonexistent author.
57 'motyw/nonexistent/', # Nonexistent theme.
58 'zh.json', # Nonexistent language.
62 for expected_status, urls in url_map.items():
64 status = self.client.get(prefix + url).status_code
66 status, expected_status,
67 "Wrong status code for '%s'. Expected %d, got %d." % (prefix + url, expected_status, status))