diff options
author | Benjamin Saller <bcsaller@objectrealms.net> | 2007-06-21 21:21:12 (GMT) |
---|---|---|
committer | Benjamin Saller <bcsaller@objectrealms.net> | 2007-06-21 21:21:12 (GMT) |
commit | 746032d4a967aa3aa97d13f7f15efd8069f35f05 (patch) | |
tree | 3ce00178f149860b5ba7782984cfc5a28c9168f4 /tests | |
parent | a6760376b32520ca694e3ee5ff1fe8ae6d0ebeaf (diff) |
all tests pass on the multi-backend code
Diffstat (limited to 'tests')
-rw-r--r-- | tests/milestone_1.txt | 14 | ||||
-rw-r--r-- | tests/query.txt | 9 | ||||
-rw-r--r-- | tests/sugar_demo_may17.txt | 6 | ||||
-rw-r--r-- | tests/test_backingstore.py | 4 | ||||
-rw-r--r-- | tests/test_model.py | 8 |
5 files changed, 30 insertions, 11 deletions
diff --git a/tests/milestone_1.txt b/tests/milestone_1.txt index 2c5cb83..87e627a 100644 --- a/tests/milestone_1.txt +++ b/tests/milestone_1.txt @@ -14,7 +14,11 @@ datastore. First, create and connect the store. >>> from olpc.datastore import DataStore ->>> ds = DataStore('/tmp/test_ds', 'sqlite://') +>>> from olpc.datastore import backingstore +>>> ds = DataStore() +>>> ds.registerBackend(backingstore.FileBackingStore) +>>> ds.mount("/tmp/test_ds") +True Because there is newly created we are going to quickly populate the datastore with some content. @@ -37,7 +41,13 @@ Now we should be able to test the first requirement. A find command with out any parameters will return everything in the store. * Get an object from the store given his uid. ->>> first_uid = results[0]['uid'] + +Here we manually cycle through the results looking for the title we +want. +>>> for item in results: +... if item['title'] == 'Document 1': +... first_uid = item['uid'] +... break >>> c1 = ds.get(first_uid) * Get the object metadata. diff --git a/tests/query.txt b/tests/query.txt index ff65455..e0217a2 100644 --- a/tests/query.txt +++ b/tests/query.txt @@ -1,5 +1,3 @@ -Status: Alpha - Implemented - This document outlines the basic usage of the olpc.datastore.query and olpc.datastore.model modules. Not that these are not use independ of the olpc.datastore.backend which in turn is only accessed through the @@ -12,8 +10,8 @@ First lets create a query manager >>> from olpc.datastore.query import DefaultQueryManager >>> from olpc.datastore.model import Property ->>> qm = DefaultQueryManager("sqlite://", fulltext_repo='/tmp/_test_fulltext') ->>> qm.prepare(None, None) +>>> qm = DefaultQueryManager("/tmp/_test_index", fulltext_repo='/tmp/_test_fulltext') +>>> qm.prepare() True That will create the memory backed database which will be used in this @@ -233,5 +231,6 @@ True Now for politeness we shut everything down >>> qm.stop() ->>> import shutil +>>> import shutil, os >>> shutil.rmtree('/tmp/_test_fulltext') +>>> os.unlink('/tmp/_test_index.db') diff --git a/tests/sugar_demo_may17.txt b/tests/sugar_demo_may17.txt index 1b2dea4..cfeefdf 100644 --- a/tests/sugar_demo_may17.txt +++ b/tests/sugar_demo_may17.txt @@ -1,7 +1,11 @@ How Sugar will interact with the DS for the May 17th demo in Argentina: >>> from olpc.datastore import DataStore ->>> ds = DataStore('/tmp/test_ds', 'sqlite://') +>>> from olpc.datastore import backingstore +>>> ds = DataStore() +>>> ds.registerBackend(backingstore.FileBackingStore) +>>> ds.mount("/tmp/test_ds") +True Create an entry without data: >>> uid = ds.create(dict(title="New entry"), '') diff --git a/tests/test_backingstore.py b/tests/test_backingstore.py index 263b775..36d62ed 100644 --- a/tests/test_backingstore.py +++ b/tests/test_backingstore.py @@ -2,6 +2,7 @@ import unittest from StringIO import StringIO from olpc.datastore import backingstore +from sqlalchemy import clear_mappers import os DEFAULT_STORE = '/tmp/_bs_test' @@ -10,8 +11,11 @@ class Test(unittest.TestCase): def tearDown(self): if os.path.exists(DEFAULT_STORE): os.system("rm -rf %s" % DEFAULT_STORE) + + clear_mappers() def test_fsstore(self): + clear_mappers() bs = backingstore.FileBackingStore(DEFAULT_STORE) bs.initialize_and_load() bs.create_descriptor() diff --git a/tests/test_model.py b/tests/test_model.py index 65da1eb..5ba7bd0 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -2,7 +2,7 @@ import unittest from testutils import tmpData from olpc.datastore import DataStore -from olpc.datastore import model +from olpc.datastore import model, backingstore import datetime class Test(unittest.TestCase): @@ -16,8 +16,10 @@ class Test(unittest.TestCase): assert p.value.isoformat() == n.isoformat() def test_binaryproperty(self): - ds = DataStore('/tmp/test_ds', 'sqlite://') - + ds = DataStore() + ds.registerBackend(backingstore.FileBackingStore) + ds.mount('/tmp/test_ds') + 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), |