X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f4c540df2eb34b761e08f67396c22daf3b14ca10..180fe27d469608a6f3cdd5249311f93a5bc437b5:/apps/search/tests/index.py?ds=inline diff --git a/apps/search/tests/index.py b/apps/search/tests/index.py new file mode 100644 index 000000000..c2b9110cf --- /dev/null +++ b/apps/search/tests/index.py @@ -0,0 +1,32 @@ +from __future__ import with_statement + +from search import Index, Search +from catalogue import models +from catalogue.test_utils import WLTestCase +from lucene import PolishAnalyzer, Version +#from nose.tools import raises +from os import path + + +class BookSearchTests(WLTestCase): + def setUp(self): + WLTestCase.setUp(self) + + txt = path.join(path.dirname(__file__), 'files/fraszka-do-anusie.xml') + self.book = models.Book.from_xml_file(txt) + + search = Index() #PolishAnalyzer(Version.LUCENE_34)) + with search: + search.index_book(self.book) + print "index: %s" % search + + def test_search(self): + search = Search() + bks,_= search.search("wolne") + self.assertEqual(len(bks), 1) + self.assertEqual(bks[0].id, 1) + + bks,_= search.search("technical_editors: sutkowska") + self.assertEqual(len(bks), 1) + self.assertEqual(bks[0].id, 1) +