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-21 08:13:59 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-06-21 08:13:59 (GMT)
commita6760376b32520ca694e3ee5ff1fe8ae6d0ebeaf (patch)
tree60d7b0dd9a5be71b1849edf8fe8e90a5a7aa3068 /tests
parent0b3184b32ec287b0ff96de49e4827af4e2392e6c (diff)
initial backingstore changes with some tests
modifing find next
Diffstat (limited to 'tests')
-rw-r--r--tests/test_backingstore.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_backingstore.py b/tests/test_backingstore.py
new file mode 100644
index 0000000..263b775
--- /dev/null
+++ b/tests/test_backingstore.py
@@ -0,0 +1,49 @@
+import unittest
+from StringIO import StringIO
+
+from olpc.datastore import backingstore
+import os
+
+DEFAULT_STORE = '/tmp/_bs_test'
+
+class Test(unittest.TestCase):
+ def tearDown(self):
+ if os.path.exists(DEFAULT_STORE):
+ os.system("rm -rf %s" % DEFAULT_STORE)
+
+ def test_fsstore(self):
+ bs = backingstore.FileBackingStore(DEFAULT_STORE)
+ bs.initialize_and_load()
+ bs.create_descriptor()
+ desc = bs.descriptor()
+ assert 'id' in desc
+ assert 'title' in desc
+ assert 'uri' in desc
+
+
+ d = """This is a test"""
+ d2 = "Different"
+
+ c = bs.create(dict(title="A"), StringIO(d))
+ obj = bs.get(c.id)
+ assert obj.get_property('title') == "A"
+ got = obj.file.read()
+ assert got == d
+
+ bs.update(c.id, dict(title="B"), StringIO(d2))
+ obj = bs.get(c.id)
+ assert obj.get_property('title') == "B"
+ got = obj.file.read()
+ assert got == d2
+
+ bs.delete(c.id)
+ self.failUnlessRaises(KeyError, bs.get, c.id)
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(Test))
+ return suite
+
+if __name__ == "__main__":
+ unittest.main()
+