X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/5e983f642ea537225bf3a20e97fca281c8fdc915..070d93a055b8dfd594664db308b310785d59af70:/apps/dictionary/tests.py diff --git a/apps/dictionary/tests.py b/apps/dictionary/tests.py new file mode 100755 index 000000000..89d2ab9fb --- /dev/null +++ b/apps/dictionary/tests.py @@ -0,0 +1,48 @@ +# -*- 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 django.core.files.base import ContentFile +from catalogue.test_utils import * +from catalogue.models import Book +from dictionary.models import Note + + +class DictionaryTests(WLTestCase): + + def setUp(self): + WLTestCase.setUp(self) + self.book_info = BookInfoStub( + url=u"http://wolnelektury.pl/example/default-book", + about=u"http://wolnelektury.pl/example/URI/default_book", + title=u"Default Book", + author=PersonStub(("Jim",), "Lazy"), + kind="X-Kind", + genre="X-Genre", + epoch="X-Epoch", + ) + + def test_book_with_fragment(self): + BOOK_TEXT = """ + + rose --- kind of a flower. + + """ + + book = Book.from_text_and_meta(ContentFile(BOOK_TEXT), self.book_info) + + self.assertEqual( + len(self.client.get('/przypisy/').context['object_list']), + 1, + 'There should be a note on the note list.') + + self.assertEqual( + len(self.client.get('/przypisy/a/').context['object_list']), + 0, + 'There should not be a note for the letter A.') + + self.assertEqual( + len(self.client.get('/przypisy/r/').context['object_list']), + 1, + 'There should be a note for the letter R.') +