Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Saller <bcsaller@objectrealms.net>2007-06-29 09:07:58 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-06-29 09:07:58 (GMT)
commit251900b46bf2dc42dcacdd1cb8ae4c6447a03a27 (patch)
treedfd962fde88ac72999f3952f333b74161d4184bc /tests
parentd23ee8a383f9abd30f7f4f979d843c4d510033a4 (diff)
sanitize dbus input to methods by reducing it to base types
save mount options persistently factored out bits of model into a domain class to anticipate a xapian move
Diffstat (limited to 'tests')
-rw-r--r--tests/mountpoints.txt19
-rw-r--r--tests/query.txt35
-rw-r--r--tests/test_backingstore.py4
3 files changed, 49 insertions, 9 deletions
diff --git a/tests/mountpoints.txt b/tests/mountpoints.txt
index 2f3bb51..9a821b5 100644
--- a/tests/mountpoints.txt
+++ b/tests/mountpoints.txt
@@ -13,8 +13,7 @@ mounting a backingstore on the datastore.
>>> from olpc.datastore import DataStore
>>> from olpc.datastore import backingstore
>>> from testutils import tmpData
->>> import os
-
+>>> import dbus
Here we create a datastore, and mount a backingstore on tmp. By
@@ -108,6 +107,22 @@ If that worked it should have imported content on load().
>>> assert result[0]['mountpoint'] == mp3
+Let's unmount 'Fake USB' and then remount it with some options passed
+as DBus data.
+
+>>> ds.unmount(mp3)
+
+>>> mp3 = ds.mount("inplace:/tmp/store3", dict(title=dbus.String("Fake USB again")))
+
+>>> result, count = ds.find(dict(fulltext="four"))
+>>> assert count == 1
+>>> assert result[0]['mountpoint'] == mp3
+
+>>> mp = ds.mountpoints[mp3]
+
+Check for the new value in the descriptor
+
+>>> assert mp.descriptor()['title'] == 'Fake USB again'
>>> ds.stop(); del ds
diff --git a/tests/query.txt b/tests/query.txt
index 151db74..d3a69dd 100644
--- a/tests/query.txt
+++ b/tests/query.txt
@@ -4,6 +4,9 @@ the olpc.datastore.backend which in turn is only accessed through the
olpc.datastore module. This is intended only to document the innards
of those modules.
+>>> import os
+>>> assert os.system('rm -rf /tmp/_test_index') == 0
+>>> assert os.system('rm -rf /tmp/_test_fulltext') == 0
First lets create a query manager
@@ -38,14 +41,14 @@ Find will now return this object.
We can examine the Properties of this object.
>>> a.properties
-[... <Property title:'New Content' of...>, ...]
+[... <TextProperty title:'New Content'>, ...]
This returned a list of all properties on the Content object in which
case we can find the property by enumeration. The other option is
using the get_properties call on Content
>>> a.get_properties(key='title')
-[<Property title:'New Content' of ...>]
+[<TextProperty title:'New Content'>]
Using the query manager API we are able to update the
properties. Using this form automatically synchronizes with the
@@ -55,11 +58,11 @@ that this works lets attach another property.
A request for title still returns only the title property.
>>> a.get_properties(key='title')
-[<Property title:'New Content' of ...>]
+[<TextProperty title:'New Content'>]
And a request for author works as expected.
>>> a.get_properties(key='author')
-[<Property author:'Benjamin' of ...>]
+[<Property author:'Benjamin'>]
>>> qm.update(a, dict(foo='bar'))
>>> set([p.key for p in a.properties]) == set(['title', 'mtime', 'ctime', 'language', 'mime_type', 'author', 'foo'])
@@ -224,10 +227,32 @@ True
>>> qm.find(fulltext="amazed", author="Benjamin") == ([a], 1)
True
->>> qm.update(a, filelike="test.doc")
+>>> qm.update(a, dict(title="titled indeed"), filelike="test.doc")
>>> qm.find(fulltext="amazed", author="Benjamin") == ([a], 1)
True
+For the last example we can see that we also updated the title. Here
+we show that because title is a 'text' property, rather than a simple
+string its contents will be available to the text indexing engine as
+well.
+
+Searching for a direct match on the property works.
+
+>>> qm.find(title="titled indeed") == ([a], 1)
+True
+
+Doing a search for text internal to the title doesn't however.
+
+>>> qm.find(title="indeed") == ([a], 1)
+False
+
+Searching for it in the fulltext index does return a result.
+
+>>> qm.find(fulltext="indeed") == ([a], 1)
+True
+
+
+
Now for politeness we shut everything down
>>> qm.stop()
diff --git a/tests/test_backingstore.py b/tests/test_backingstore.py
index 36d62ed..28fdeba 100644
--- a/tests/test_backingstore.py
+++ b/tests/test_backingstore.py
@@ -21,9 +21,9 @@ class Test(unittest.TestCase):
bs.create_descriptor()
desc = bs.descriptor()
assert 'id' in desc
- assert 'title' in desc
assert 'uri' in desc
-
+ assert 'title' in desc
+ assert desc['title'] is not None
d = """This is a test"""
d2 = "Different"