fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into sunburnt
[wolnelektury.git]
/
apps
/
search
/
tests
/
index.py
diff --git
a/apps/search/tests/index.py
b/apps/search/tests/index.py
index
ef253e4
..
5155a84
100644
(file)
--- a/
apps/search/tests/index.py
+++ b/
apps/search/tests/index.py
@@
-1,33
+1,24
@@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
-
-from __future__ import with_statement
-
from django.conf import settings
from django.conf import settings
-from search import Index, Search, IndexStore, JVM, SearchResult
-from catalogue import models
+from django.test.utils import override_settings
from catalogue.test_utils import WLTestCase
from lucene import PolishAnalyzer, Version
from catalogue.test_utils import WLTestCase
from lucene import PolishAnalyzer, Version
-#from nose.tools import raises
from os import path
from os import path
+import tempfile
+from catalogue import models
+from search import Search, SearchResult
+@override_settings(
+ SEARCH_INDEX = tempfile.mkdtemp(prefix='djangotest_search_'),
+)
class BookSearchTests(WLTestCase):
def setUp(self):
class BookSearchTests(WLTestCase):
def setUp(self):
- JVM.attachCurrentThread()
WLTestCase.setUp(self)
WLTestCase.setUp(self)
- settings.NO_SEARCH_INDEX = False
- settings.SEARCH_INDEX = path.join(settings.MEDIA_ROOT, 'search')
txt = path.join(path.dirname(__file__), 'files/fraszka-do-anusie.xml')
txt = path.join(path.dirname(__file__), 'files/fraszka-do-anusie.xml')
- self.book = models.Book.from_xml_file(txt)
-
- index = Index()
- index.open()
- try:
- index.index_book(self.book)
- except:
- index.close()
-
+ with self.settings(NO_SEARCH_INDEX=False):
+ self.book = models.Book.from_xml_file(txt)
self.search = Search()
def test_search_perfect_book_author(self):
self.search = Search()
def test_search_perfect_book_author(self):
@@
-47,8
+38,7
@@
class BookSearchTests(WLTestCase):
b.book_id == self.book.id
a = SearchResult.aggregate(books)
# just one fragment hit.
b.book_id == self.book.id
a = SearchResult.aggregate(books)
# just one fragment hit.
- assert len(filter(lambda x: x[1], a[0].hits)) == 1
- print a[0].process_hits()
+ assert len(a[0].hits) == 1
def test_search_perfect_author_title(self):
books = self.search.search_perfect_book("szarzyński anusie")
def test_search_perfect_author_title(self):
books = self.search.search_perfect_book("szarzyński anusie")