basic query using Dublin core fields works
[wolnelektury.git] / apps / search / tests / index.py
1 from __future__ import with_statement
2
3 from search import Index, Search
4 from catalogue import models
5 from catalogue.test_utils import WLTestCase
6 #from nose.tools import raises
7 from os import path
8
9
10 class BookSearchTests(WLTestCase):
11     def setUp(self):
12         WLTestCase.setUp(self)
13
14         txt = path.join(path.dirname(__file__), 'files/fraszka-do-anusie.xml')
15         self.book = models.Book.from_xml_file(txt)
16
17         search = Index()
18         with search:
19             search.index_book(self.book)
20         print "index: %s" % search
21
22     def test_search(self):
23         search = Search()
24         bks,_= search.search("wolne")
25         self.assertEqual(len(bks), 1)
26         self.assertEqual(bks[0].id, 1)
27         
28         bks,_= search.search("technical_editors: sutkowska")
29         self.assertEqual(len(bks), 1)
30         self.assertEqual(bks[0].id, 1)
31