Fundraising in PDF.
[wolnelektury.git] / src / search / tests / index.py
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.
3 #
4 from django.conf import settings
5 from django.test.utils import override_settings
6 from catalogue.test_utils import WLTestCase, get_fixture
7 from catalogue.models import Book
8 import catalogue
9 import opds
10
11
12 class BookSearchTests(WLTestCase):
13     def setUp(self):
14         WLTestCase.setUp(self)
15
16         with override_settings(NO_SEARCH_INDEX=False):
17             self.do_doktora = Book.from_xml_file(
18                 get_fixture('do-doktora.xml', opds))
19             self.do_anusie = Book.from_xml_file(
20                 get_fixture('fraszka-do-anusie.xml', catalogue))
21
22     def test_search_perfect_parts(self):
23         response = self.client.get('/szukaj/?q=Jakoż hamować')
24         res = response.context['results']
25         self.assertEqual(len(res['snippet']), 1)
26         for b, s in res['snippet'].items():
27              self.assertEqual(b.id, self.do_anusie.id)