prettier player window,
[wolnelektury.git] / apps / dictionary / tests.py
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.
4 #
5 from django.core.files.base import ContentFile
6 from catalogue.test_utils import *
7 from catalogue.models import Book
8 from dictionary.models import Note
9
10
11 class DictionaryTests(WLTestCase):
12
13     def setUp(self):
14         WLTestCase.setUp(self)
15         self.book_info = BookInfoStub(
16             url=u"http://wolnelektury.pl/example/default-book",
17             about=u"http://wolnelektury.pl/example/URI/default_book",
18             title=u"Default Book",
19             author=PersonStub(("Jim",), "Lazy"),
20             kind="X-Kind",
21             genre="X-Genre",
22             epoch="X-Epoch",
23         )
24
25     def test_book_with_footnote(self):
26         BOOK_TEXT = """<utwor>
27         <opowiadanie>
28             <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
29         </opowiadanie></utwor>
30         """
31
32         book = Book.from_text_and_meta(ContentFile(BOOK_TEXT), self.book_info)
33
34         self.assertEqual(
35             len(self.client.get('/przypisy/').context['object_list']),
36             1,
37             'There should be a note on the note list.')
38
39         self.assertEqual(
40             len(self.client.get('/przypisy/a/').context['object_list']),
41             0,
42             'There should not be a note for the letter A.')
43
44         self.assertEqual(
45             len(self.client.get('/przypisy/r/').context['object_list']),
46             1,
47             'There should be a note for the letter R.')
48