Add grammar to tags. Also: respect custom tag slugs on publishing.
[wolnelektury.git] / src / dictionary / tests.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 from django.core.files.base import ContentFile
5 from catalogue.test_utils import *
6 from catalogue.models import Book
7
8
9 class DictionaryTests(WLTestCase):
10
11     def setUp(self):
12         WLTestCase.setUp(self)
13         self.book_info = BookInfoStub(
14             author=PersonStub(("Jim",), "Lazy"),
15             kind="X-Kind",
16             genre="X-Genre",
17             epoch="X-Epoch",
18             **info_args("Default Book")
19         )
20
21     def test_book_with_footnote(self):
22         book_text = b"""<utwor>
23         <opowiadanie>
24             <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
25             <akap><pe><slowo_obce>rose</slowo_obce> --- kind of a flower.</pe></akap>
26             <akap><pe><slowo_obce>rose</slowo_obce> (techn.) --- #FF007F.</pe></akap>
27         </opowiadanie></utwor>
28         """
29
30         book = Book.from_text_and_meta(ContentFile(book_text), self.book_info)
31
32         self.assertEqual(
33             len(self.client.get('/przypisy/').context['object_list']),
34             2,
35             'There should be two notes on the note list.')
36
37         self.assertEqual(
38             len(self.client.get('/przypisy/?ltr=a').context['object_list']),
39             0,
40             'There should not be a note for the letter A.')
41
42         self.assertEqual(
43             len(self.client.get('/przypisy/?ltr=r').context['object_list']),
44             2,
45             'Both notes start with the letter R.')
46
47         self.assertEqual(
48             len(self.client.get('/przypisy/?qual=techn.').context['object_list']),
49             1,
50             'There should be a note qualified with \'techn.\' qualifier.')