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-27 21:06:56 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-07-27 21:06:56 (GMT)
commit21b3150356031bfed0e833d148c4f370364c3164 (patch)
tree8029d47b603d4a5824a0685b4edcb99cfbdc72a9 /tests
parentad0cad894d78da610ccdb3cea6b8df6539f3a2bf (diff)
proposed fixes for:
#2057 #2445 #2459
Diffstat (limited to 'tests')
-rw-r--r--tests/milestone_2.txt7
-rw-r--r--tests/mountpoints.txt29
-rw-r--r--tests/properties.txt14
-rw-r--r--tests/runalltests.py2
-rw-r--r--tests/test_model.py9
5 files changed, 42 insertions, 19 deletions
diff --git a/tests/milestone_2.txt b/tests/milestone_2.txt
index 73fd43a..551e1e3 100644
--- a/tests/milestone_2.txt
+++ b/tests/milestone_2.txt
@@ -10,12 +10,11 @@ First clean up from any other tests.
>>> from olpc.datastore import backingstore, model
>>> ds = DataStore()
>>> ds.registerBackend(backingstore.FileBackingStore)
->>> dm = model.defaultModel.copy().addField('year', 'int').addField('month', 'string')
->>> assert ds.mount("/tmp/test_ds", {'indexmanager.model' : dm})
+>>> assert ds.mount("/tmp/test_ds")
->>> a = ds.create(dict(title="Content A", author="Bob", year="1999", month="Jan"), '')
->>> b = ds.create(dict(title="Content B", author="Alice", year="2000", month="Jan"), '')
+>>> a = ds.create({'title':"Content A", 'author':"Bob", 'year:int':"1999", 'month':"Jan"}, '')
+>>> b = ds.create({'title':"Content B", 'author':"Alice", 'year:int':"2000", 'month':"Jan"}, '')
Find should return both
>>> def find2uids(results): return [i['uid'] for i in results[0]]
diff --git a/tests/mountpoints.txt b/tests/mountpoints.txt
index 304d4eb..45a359a 100644
--- a/tests/mountpoints.txt
+++ b/tests/mountpoints.txt
@@ -168,5 +168,34 @@ inplace one. Lets move the object with u1 to mp3
>>> assert count == 1
>>> assert result[0]['uid'] == pen_copy
+The file was properly created in the expected place.
+
+>>> assert os.path.exists('/tmp/store3/one.txt')
+
+
+We also need to be sure that delete commands work on inplace
+mounts. We will delete the object from the datastore and then verify
+that the file is missing.
+
+>>> ds.delete(pen_copy)
+>>> ds.complete_indexing()
+
+>>> os.path.exists('/tmp/store3/one.txt')
+False
+
+
+Now a tricky case where we corrupt the metadata on a mount and want to
+verify that we can still remount the store.
+
+>>> ds.unmount(mp3)
+>>> fp = open('/tmp/store3/.olpc.store/metainfo', 'w')
+>>> fp.seek(0)
+>>> fp.write('broken')
+>>> fp.close()
+
+>>> mp3 = ds.mount("inplace:/tmp/store3", dict(title="Fake USB from broken"))
+>>> mp = ds.mountpoints[mp3]
+>>> assert mp.descriptor()['title'] == 'Fake USB from broken'
+
>>> ds.stop(); del ds
diff --git a/tests/properties.txt b/tests/properties.txt
index 4a95ec4..6c3c91b 100644
--- a/tests/properties.txt
+++ b/tests/properties.txt
@@ -19,20 +19,18 @@ Set up two mount points.
Extend the model to retain a 'year' property used below.
->>> dm = model.defaultModel.copy().addField('year', "number")
-
Mount a couple of stores.
->>> mp1 = ds.mount("/tmp/store1", {'title' : "Primary Storage", 'indexmanager.model' : dm})
->>> mp2 = ds.mount("/tmp/store2", {'title' : "Secondary Storage", 'indexmanager.model' : dm})
+>>> mp1 = ds.mount("/tmp/store1", {'title' : "Primary Storage",})
+>>> mp2 = ds.mount("/tmp/store2", {'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"""))
+>>> u1 = ds.create({'title' : "Alpha doc", 'author' : "Ben", 'year:int' : 2000}, tmpData("""Document 1"""))
+>>> u2 = ds.create({'title' : "Beta doc", 'author' : "Ben", 'year:int' : 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"""))
+>>> u3 = ds.create({'title' : "Delta doc", 'author' :"HAL", 'year:int' : 2000, 'mountpoint' : mp2}, tmpData("""Document 3"""))
+>>> u4 = ds.create({'title' : "Gamma doc", 'author' : "HAL", 'year:int' : 2001, 'mountpoint' : mp2}, tmpData("""Document 4"""))
Now we should be able to discover things about the system properties.
>>> ds.complete_indexing()
diff --git a/tests/runalltests.py b/tests/runalltests.py
index 564cee2..8fee87e 100644
--- a/tests/runalltests.py
+++ b/tests/runalltests.py
@@ -31,7 +31,7 @@ doctests = [
]
doctest_options = doctest.ELLIPSIS
-doctest_options |= doctest.REPORT_ONLY_FIRST_FAILURE
+#doctest_options |= doctest.REPORT_ONLY_FIRST_FAILURE
def test_suite():
diff --git a/tests/test_model.py b/tests/test_model.py
index 059a128..6d171c1 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -28,18 +28,15 @@ class Test(unittest.TestCase):
ds = DataStore()
ds.registerBackend(backingstore.FileBackingStore)
- #add a custom field to the model
- dm = model.defaultModel.copy().addField('thumbnail', 'binary')
-
-
- ds.mount(DEFAULT_STORE, {'indexmanager.model' : dm})
+
+ ds.mount(DEFAULT_STORE)
n = datetime.datetime.now()
data = open('test.jpg', 'r').read()
# binary data with \0's in it can cause dbus errors here
fn = tmpData("with image\0\0 prop")
# The key types are looked up in the model now
- uid = ds.create({'title' : "Document 1", 'thumbnail' : data, 'ctime' : n.isoformat()}, fn)
+ uid = ds.create({'title' : "Document 1", 'thumbnail:binary' : data, 'ctime' : n.isoformat()}, fn)
ds.complete_indexing()