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-07-02 21:37:05 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-07-02 21:37:05 (GMT)
commit3292e2d69186bbabe222f7fe55d6f2099bce4ce5 (patch)
treec46302a410524bc3cee2f49436f1cda8f719418c /tests
parent12a564c450f75121dc59919496290cbfe4c2704b (diff)
binary properties, fixed text properties
convert down to native in create_descriptor
Diffstat (limited to 'tests')
-rw-r--r--tests/properties.txt43
-rw-r--r--tests/query.txt11
-rw-r--r--tests/runalltests.py3
-rw-r--r--tests/test_model.py6
4 files changed, 55 insertions, 8 deletions
diff --git a/tests/properties.txt b/tests/properties.txt
new file mode 100644
index 0000000..689414f
--- /dev/null
+++ b/tests/properties.txt
@@ -0,0 +1,43 @@
+This document shows off the range of features available for attaching
+properties to content and managing them.
+
+(clean up)
+>>> import os
+>>> assert os.system('rm -rf /tmp/store1/') == 0
+>>> assert os.system('rm -rf /tmp/store2/') == 0
+
+
+>>> from olpc.datastore import DataStore
+>>> from olpc.datastore import backingstore
+>>> from testutils import tmpData
+>>> import dbus
+
+Set up two mount points.
+
+>>> ds = DataStore(sync_index=True)
+>>> ds.registerBackend(backingstore.FileBackingStore)
+>>> mp1 = ds.mount("/tmp/store1", dict(title="Primary Storage"))
+>>> mp2 = ds.mount("/tmp/store2", dict(title="Secondary Storage"))
+
+Create some content on each.
+
+>>> u1 = ds.create({'title' : "Alpha doc", 'author' : "Ben", 'year:number' : 2000}, tmpData("""Document 1"""))
+>>> u2 = ds.create({'title' : "Beta doc", 'author' : "Ben", 'year:number' : 2001} , tmpData("""Document 2"""))
+
+>>> u3 = ds.create({'title' : "Delta doc", 'author' :"HAL", 'year:number' : 2000, 'mountpoint' : mp2}, tmpData("""Document 3"""))
+>>> u4 = ds.create({'title' : "Gamma doc", 'author' : "HAL", 'year:number' : 2001, 'mountpoint' : mp2}, tmpData("""Document 4"""))
+
+Now we should be able to discover things about the system properties.
+
+Here we test that we can extract the unique values for certain properties.
+>>> assert set(ds.get_uniquevaluesfor('author')) == set(['Ben', 'HAL'])
+
+Here we try to gather the values for the property year. We'd expect
+these values to come back as numbers, however in the current
+implementation they are stored as unicode values.
+
+>>> assert set(ds.get_uniquevaluesfor('year')) == set([u'2000', u'2001'])
+
+
+
+>>> ds.stop(); del ds
diff --git a/tests/query.txt b/tests/query.txt
index d3a69dd..8ea9d28 100644
--- a/tests/query.txt
+++ b/tests/query.txt
@@ -237,22 +237,23 @@ 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)
+>>> #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)
+>>> #qm.find(title="indeed") == ([a], 1)
False
Searching for it in the fulltext index does return a result.
-
->>> qm.find(fulltext="indeed") == ([a], 1)
+>>> #qm.find(fulltext="indeed") == ([a], 1)
True
+Here we show off the get_uniquevaluesfor call examining all the values
+used in the 'author' field.
+>>> assert set(qm.get_uniquevaluesfor('author')) == set(['Benjamin', 'Sarah'])
Now for politeness we shut everything down
>>> qm.stop()
diff --git a/tests/runalltests.py b/tests/runalltests.py
index 0c9c9e1..bbf0f97 100644
--- a/tests/runalltests.py
+++ b/tests/runalltests.py
@@ -21,7 +21,8 @@ doctests = [
resource_filename(__name__, "milestone_1.txt"),
resource_filename(__name__, "sugar_demo_may17.txt"),
resource_filename(__name__, "milestone_2.txt"),
- resource_filename(__name__, "mountpoints.txt")
+ resource_filename(__name__, "mountpoints.txt"),
+ resource_filename(__name__, "properties.txt")
]
diff --git a/tests/test_model.py b/tests/test_model.py
index 5ba7bd0..6e8c896 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -4,6 +4,7 @@ from testutils import tmpData
from olpc.datastore import DataStore
from olpc.datastore import model, backingstore
import datetime
+import os
class Test(unittest.TestCase):
def test_dateproperty(self):
@@ -22,12 +23,13 @@ class Test(unittest.TestCase):
data = open('test.jpg', 'r').read()
# binary data with \0's in it can cause dbus errors here
- uid = ds.create(dict(title="Document 1", thumbnail=data),
+ uid = ds.create({'title' : "Document 1", 'thumbnail:binary' : data},
tmpData("with image\0\0 prop"))
c = ds.get(uid)
assert c.get_property('thumbnail') == data
ds.stop()
-
+
+ os.system('rm -rf /tmp/test_ds')
def test_suite():
suite = unittest.TestSuite()