mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-05-03 21:14:49 +00:00
Removed xapian_search method in test suite. Is no longer required.
This commit is contained in:
parent
350beefe98
commit
a3e90e4bbf
1 changed files with 2 additions and 32 deletions
|
|
@ -127,38 +127,11 @@ class XapianSearchBackendTestCase(TestCase):
|
|||
|
||||
super(XapianSearchBackendTestCase, self).tearDown()
|
||||
|
||||
def xapian_search(self, query_string):
|
||||
database = xapian.Database(settings.HAYSTACK_XAPIAN_PATH)
|
||||
if query_string:
|
||||
qp = xapian.QueryParser()
|
||||
qp.set_database(database)
|
||||
query = qp.parse_query(query_string, xapian.QueryParser.FLAG_WILDCARD)
|
||||
else:
|
||||
query = xapian.Query(query_string) # Empty query matches all
|
||||
enquire = xapian.Enquire(database)
|
||||
enquire.set_query(query)
|
||||
matches = enquire.get_mset(0, database.get_doccount())
|
||||
|
||||
document_list = []
|
||||
|
||||
for match in matches:
|
||||
app_label, module_name, pk, model_data = pickle.loads(match.document.get_data())
|
||||
for key, value in model_data.iteritems():
|
||||
model_data[key] = _marshal_value(value)
|
||||
model_data['id'] = u'%s.%s.%d' % (app_label, module_name, pk)
|
||||
document_list.append(model_data)
|
||||
|
||||
return document_list
|
||||
|
||||
def test_update(self):
|
||||
self.backend.update(self.index, self.sample_objs)
|
||||
|
||||
self.assertEqual(self.backend.document_count(), 3)
|
||||
self.assertEqual([dict(doc) for doc in self.xapian_search('')], [
|
||||
{'flag': u't', 'name': u'david1', 'name_exact': u'david1', 'tags': u"['a', 'b', 'c']", 'keys': u'[1, 2, 3]', 'text': u'indexed!\n1', 'sites': u"['1', '2', '3']", 'titles': u"['object one title one', 'object one title two']", 'pub_date': u'20090224000000', 'value': u'000000000005', 'month': u'02', 'id': u'tests.xapianmockmodel.1', 'slug': u'http://example.com/1/', 'url': u'http://example.com/1/', 'popularity': '\xca\x84', 'django_id': u'1', 'django_ct': u'tests.xapianmockmodel', 'empty': u''},
|
||||
{'flag': u'f', 'name': u'david2', 'name_exact': u'david2', 'tags': u"['ab', 'bc', 'cd']", 'keys': u'[2, 4, 6]', 'text': u'indexed!\n2', 'sites': u"['2', '4', '6']", 'titles': u"['object two title one', 'object two title two']", 'pub_date': u'20090223000000', 'value': u'000000000010', 'month': u'02', 'id': u'tests.xapianmockmodel.2', 'slug': u'http://example.com/2/', 'url': u'http://example.com/2/', 'popularity': '\xb4p', 'django_id': u'2', 'django_ct': u'tests.xapianmockmodel', 'empty': u''},
|
||||
{'flag': u't', 'name': u'david3', 'name_exact': u'david3', 'tags': u"['an', 'to', 'or']", 'keys': u'[3, 6, 9]', 'text': u'indexed!\n3', 'sites': u"['3', '6', '9']", 'titles': u"['object three title one', 'object three title two']", 'pub_date': u'20090222000000', 'value': u'000000000015', 'month': u'02', 'id': u'tests.xapianmockmodel.3', 'slug': u'http://example.com/3/', 'url': u'http://example.com/3/', 'popularity': '\xcb\x98', 'django_id': u'3', 'django_ct': u'tests.xapianmockmodel', 'empty': u''}
|
||||
])
|
||||
self.assertEqual([result.pk for result in self.backend.search(xapian.Query(''))['results']], [1, 2, 3])
|
||||
|
||||
def test_duplicate_update(self):
|
||||
self.backend.update(self.index, self.sample_objs)
|
||||
|
|
@ -172,10 +145,7 @@ class XapianSearchBackendTestCase(TestCase):
|
|||
|
||||
self.backend.remove(self.sample_objs[0])
|
||||
self.assertEqual(self.backend.document_count(), 2)
|
||||
self.assertEqual([dict(doc) for doc in self.xapian_search('')], [
|
||||
{'flag': u'f', 'name': u'david2', 'name_exact': u'david2', 'tags': u"['ab', 'bc', 'cd']", 'keys': u'[2, 4, 6]', 'text': u'indexed!\n2', 'sites': u"['2', '4', '6']", 'titles': u"['object two title one', 'object two title two']", 'pub_date': u'20090223000000', 'value': u'000000000010', 'month': u'02', 'id': u'tests.xapianmockmodel.2', 'slug': u'http://example.com/2/', 'url': u'http://example.com/2/', 'popularity': '\xb4p', 'django_id': u'2', 'django_ct': u'tests.xapianmockmodel', 'empty': u''},
|
||||
{'flag': u't', 'name': u'david3', 'name_exact': u'david3', 'tags': u"['an', 'to', 'or']", 'keys': u'[3, 6, 9]', 'text': u'indexed!\n3', 'sites': u"['3', '6', '9']", 'titles': u"['object three title one', 'object three title two']", 'pub_date': u'20090222000000', 'value': u'000000000015', 'month': u'02', 'id': u'tests.xapianmockmodel.3', 'slug': u'http://example.com/3/', 'url': u'http://example.com/3/', 'popularity': '\xcb\x98', 'django_id': u'3', 'django_ct': u'tests.xapianmockmodel', 'empty': u''}
|
||||
])
|
||||
self.assertEqual([result.pk for result in self.backend.search(xapian.Query(''))['results']], [2, 3])
|
||||
|
||||
def test_clear(self):
|
||||
self.backend.update(self.index, self.sample_objs)
|
||||
|
|
|
|||
Loading…
Reference in a new issue