diff options
Diffstat (limited to 'tests/milestone_1.txt')
-rw-r--r-- | tests/milestone_1.txt | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/tests/milestone_1.txt b/tests/milestone_1.txt deleted file mode 100644 index 35e8fb6..0000000 --- a/tests/milestone_1.txt +++ /dev/null @@ -1,89 +0,0 @@ -The initial requirements are as follows: - -* Get the unique ids of all the objects in the store. -* Get an object from the store given his uid. -* Get the object metadata. -* Get the object file. -* Push the changes made to the file back to the store. -* Update the metadata of an object. - -Below I enumerate each point showing how this is performed on a local -datastore. - - -First, create and connect the store. ->>> import os ->>> assert os.system('rm -rf /tmp/test_ds') == 0 - - ->>> from olpc.datastore import DataStore ->>> from olpc.datastore import backingstore ->>> ds = DataStore() ->>> ds.registerBackend(backingstore.FileBackingStore) ->>> assert ds.mount("/tmp/test_ds") - -Because there is newly created we are going to quickly populate the -datastore with some content. - ->>> from testutils import tmpData - ->>> assert ds.create(dict(title="Document 1"), tmpData("""this is the first document""")) ->>> assert ds.create(dict(title="Document 2"), tmpData("""this is the second document""")) - -We can also create an object w/o any associated file data ->>> assert ds.create(dict(title="Web Session", url="http://google.com")) - -Note that we retain no reference to the created documents. - -Now we should be able to test the first requirement. -* Get the unique ids of all the objects in the store. - ->>> ds.complete_indexing() - ->>> results, count = ds.find() - -A find command with out any parameters will return everything in the store. - -* Get an object from the store given its 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. ->>> c1.properties -{...} - -* Get the object file. ->>> c1.filename -'/tmp/...' - ->>> c1.contents -'this is the first document' ->>> c1.file -<open file ...> - - - -Now we can modify that file and then -* Push the changes made to the file back to the store. -* Update the metadata of an object. - ->>> fn = c1.filename ->>> fp = open(fn, 'a') ->>> print >>fp, "more content" ->>> fp.close() ->>> ds.update(first_uid, dict(title="Newish Content"), fn) - - -We can also remove the file from the repository. ->>> ds.delete(first_uid) - -This is the basis of milestone 1. - ->>> ds.stop() ->>> assert os.system('rm -rf /tmp/test_ds') == 0 |