diff options
author | Benjamin Saller <bcsaller@objectrealms.net> | 2007-07-13 04:28:30 (GMT) |
---|---|---|
committer | Benjamin Saller <bcsaller@objectrealms.net> | 2007-07-13 04:28:30 (GMT) |
commit | a41d2d5ca21115f3b76a789f5874f35dca089a3d (patch) | |
tree | 42ddcb1db77c01ecba8815d1f04b56348c44b145 | |
parent | 32728d52c6099933df7d452003248634c61b07a2 (diff) |
repr on content
show a more complex query in the test
-rw-r--r-- | src/olpc/datastore/model.py | 14 | ||||
-rw-r--r-- | tests/test_xapianindex.py | 7 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/olpc/datastore/model.py b/src/olpc/datastore/model.py index 80522a2..18d409f 100644 --- a/src/olpc/datastore/model.py +++ b/src/olpc/datastore/model.py @@ -134,7 +134,11 @@ class Content(object): self._doc = xapdoc self._backingstore = backingstore self._file = None - + + def __repr__(self): + return "<%s %s>" %(self.__class__.__name__, + self.properties) + def get_property(self, key, default=_marker): result = self._doc.data.get(key, default) if result is _marker: raise KeyError(key) @@ -210,14 +214,6 @@ class Content(object): def noop(value): return value -# Xapian doesn't have real binary storage, rather these keys will get -# indexed it its database. If the key size is too large the indexing -# will fail -# there are two solutions -- divert the storage to the backingstore -# and retain a key reference to recover it (this is the correct -# solution long term as it participates in versioning) and what I do -# now which is to insert and remove spaces into the base64 stream -# every fixed amount of characters import re base64hack = re.compile("(\S{212})") def base64enc(value): return ' '.join(base64hack.split(value.encode('base64'))) diff --git a/tests/test_xapianindex.py b/tests/test_xapianindex.py index cf39f01..db6afef 100644 --- a/tests/test_xapianindex.py +++ b/tests/test_xapianindex.py @@ -1,5 +1,3 @@ -from testutils import waitforindex - from olpc.datastore.xapianindex import IndexManager import os from datetime import datetime @@ -70,7 +68,7 @@ class Test(unittest.TestCase): #print "%s in %s %s/sec" % (count, delta, count/delta) # wait for indexing to finish - waitforindex(im) + im.complete_indexing() # test basic search performance results = list(im.search('peek')[0]) @@ -78,7 +76,8 @@ class Test(unittest.TestCase): # this indicates that we found text inside binary content that # we expected assert 'test.pdf' in set(r.get_property('filename') for r in results) - + + assert im.search('mimetype:application/pdf filename:test.pdf peek')[1] == 1 def test_suite(): |