X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/46a90d7cfe54bb6df2f99175abd0ad7d26b3da72..4c0b1c26b2e4789b194f34c907c822c55f04af3c:/apps/opds/tests/__init__.py?ds=sidebyside diff --git a/apps/opds/tests/__init__.py b/apps/opds/tests/__init__.py index d6e9ca05a..b1399aee7 100755 --- a/apps/opds/tests/__init__.py +++ b/apps/opds/tests/__init__.py @@ -1,24 +1,35 @@ # -*- 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 unittest import skipIf from lxml import etree +from django.conf import settings from django.core.files.base import ContentFile import catalogue from catalogue.test_utils import (BookInfoStub, PersonStub, info_args, WLTestCase, get_fixture) from catalogue.models import Book from librarian import WLURI, XMLNamespace +from search.index import Index, Search AtomNS = XMLNamespace("http://www.w3.org/2005/Atom") +@skipIf(getattr(settings, 'NO_SEARCH_INDEX', False), + u'Requires search server and NO_SEARCH_INDEX=False.') class OpdsSearchTests(WLTestCase): """Tests search feed in OPDS..""" def setUp(self): WLTestCase.setUp(self) - with self.settings(NO_SEARCH_INDEX=False): - self.do_doktora = Book.from_xml_file( - get_fixture('do-doktora.xml')) - self.do_anusie = Book.from_xml_file( - get_fixture('fraszka-do-anusie.xml', catalogue)) + index = Index() + index.index.delete_all() + index.index.commit() + + self.do_doktora = Book.from_xml_file( + get_fixture('do-doktora.xml')) + self.do_anusie = Book.from_xml_file( + get_fixture('fraszka-do-anusie.xml', catalogue)) def assert_finds(self, query, books): """Takes a query and tests against books expected to be found.""" @@ -40,7 +51,7 @@ class OpdsSearchTests(WLTestCase): both = set([self.do_doktora, self.do_anusie]) self.assert_finds('title=fraszka', both) self.assert_finds('title=fraszka', both) - self.assert_finds('q=title:fraszka', [self.do_doktora]) + self.assert_finds('q=title:doktora', [self.do_doktora]) def test_opds_search_author(self): """Search by author."""