diff options
author | Tomeu Vizoso <tomeu@sugarlabs.org> | 2009-02-04 11:34:37 (GMT) |
---|---|---|
committer | Tomeu Vizoso <tomeu@sugarlabs.org> | 2009-02-04 11:34:37 (GMT) |
commit | f3f36629db33c15030c84fd9228c50b1d7fbab71 (patch) | |
tree | 7f3f9d73ffc310c66113f6a0b18f67d03576e72c /bin | |
parent | 2a21c290bae0ced719920a784b17ad48b5c4adc6 (diff) |
Remove files referring to the old implementation
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/sample-client.py | 83 | ||||
-rwxr-xr-x | bin/test-indexprop.py | 49 | ||||
-rwxr-xr-x | bin/test-inplace.py | 106 |
3 files changed, 0 insertions, 238 deletions
diff --git a/bin/sample-client.py b/bin/sample-client.py deleted file mode 100755 index 12c5514..0000000 --- a/bin/sample-client.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python -import dbus -import os - -def main(): - bus = dbus.SessionBus() - datastore = bus.get_object("org.laptop.sugar.DataStore", - "/org/laptop/sugar/DataStore") - - uid = datastore.create(dict(title="from dbus", author="Benjamin"), os.path.abspath('tests/test.pdf')) - print "created uid", uid, "with binary content" - - datastore.complete_indexing() - - res, count = datastore.find(dict(fulltext="peek")) - assert count == 1, "failed to index content" - assert res[0]['uid'] == uid, "returned incorrect results" - print "found inside binary file :: PDF" - - assert datastore.find(dict(fulltext="kfdshaksjd"))[1] == 0 - print "successfully ignored bad searches" - - # try the other mimetypes - datastore.update(uid, dict(title="updated title", - mime_type="application/msword"), - os.path.abspath('tests/test.doc')) - - datastore.complete_indexing() - - assert datastore.find(dict(fulltext="inside"))[0][0]['uid'] == uid - print "found in binary file :: WORD" - - datastore.update(uid, dict(title="another updated title", - mime_type="application/vnd.oasis.opendocument.text"), - os.path.abspath('tests/test.odt')) - datastore.complete_indexing() - - assert datastore.find(dict(fulltext="amazed"))[0][0]['uid'] == uid - print "found in binary file :: ODT" - - datastore.get_properties(uid) - - assert datastore.find(dict(title="another"))[0][0]['uid'] == uid - print "found title using dict params", - - assert datastore.find("another")[0][0]['uid'] == uid - print "found title in search of all fields (as text)" - - - assert datastore.find('title:"another"')[0][0]['uid'] == uid - print "field in query field:'value' " - - datastore.delete(uid) - datastore.complete_indexing() - - print "deleted", uid - try: datastore.get_properties(uid) - except: pass - else: - print "Found deleted value... oops" - raise KeyError(uid) - - - uid2 = datastore.create(dict(title="cows", - mime_type="application/vnd.oasis.opendocument.text"), - os.path.abspath('tests/funkyabi.odt')) - - datastore.complete_indexing() - - assert datastore.find(dict(fulltext="vaca"))[0][0]['uid'] == uid2 - print "found in binary file :: ODT" - - datastore.delete(uid2) - datastore.complete_indexing() - - print "ALL GOOD" - -if __name__ == '__main__': - #from ore.main import Application - #a = Application("client", main) - #a.plugins.append('ore.main.profile_support.ProfileSupport') - #a() - main() diff --git a/bin/test-indexprop.py b/bin/test-indexprop.py deleted file mode 100755 index bf75e46..0000000 --- a/bin/test-indexprop.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python -import dbus -import os - -def main(): - bus = dbus.SessionBus() - ds = bus.get_object("org.laptop.sugar.DataStore", - "/org/laptop/sugar/DataStore") - datastore = dbus.Interface(ds, dbus_interface='org.laptop.sugar.DataStore') - - props = {'title': 'test activity', - 'title_set_by_user': '0', - 'buddies': '', - 'keep': '0', - 'icon-color': '#40011d,#79079a', - 'activity': 'org.laptop.WebActivity', - 'mime_type': ''} - - uid = datastore.create(props, '') - print "created uid", uid - datastore.complete_indexing() - props = {'title': 'test activity title changed', - 'title_set_by_user': '1', - 'buddies': '', - 'keep': '0', - 'icon-color': '#40011d,#79079a', - 'activity': 'org.laptop.WebActivity', - 'mime_type': 'text/plain'} - - datastore.update(uid, props, os.path.abspath('tests/web_data.json')) - print "updated uid", uid - datastore.complete_indexing() - - - result, count = datastore.find(dict(title='test')) - print result - assert result[0]['uid'] == uid - for k, v in result[0].items(): - print "\t", k, v - print open(datastore.get_filename(uid), 'r').read() - print "OK" - - datastore.delete(uid) - -if __name__ == '__main__': - #a = Application("client", main) - #a.plugins.append('ore.main.profile_support.ProfileSupport') - #a() - main() diff --git a/bin/test-inplace.py b/bin/test-inplace.py deleted file mode 100755 index 2d0b1af..0000000 --- a/bin/test-inplace.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/python - -import dbus -import dbus.glib -import os -import time - -import tempfile - -def tmpData(data): - """Put data into a temporary file returning the filename """ - fd, fn = tempfile.mkstemp() - os.write(fd, data) - os.close(fd) - return fn - - - -DS_DBUS_SERVICE = "org.laptop.sugar.DataStore" -DS_DBUS_INTERFACE = "org.laptop.sugar.DataStore" -DS_DBUS_PATH = "/org/laptop/sugar/DataStore" - - -# clean up any old tests -assert os.system('rm -rf /tmp/store1') == 0 - -_bus = dbus.SessionBus() -_data_store = dbus.Interface(_bus.get_object(DS_DBUS_SERVICE, DS_DBUS_PATH), DS_DBUS_INTERFACE) - -mount_id = _data_store.mount('inplace:/tmp/store1', dict(title='pen drive')) - -props = {'activity_id': dbus.String(u'461c7467f9ef6478b205a687579843fc36a98e7a'), - 'title_set_by_user': '0', - 'ctime': '2007-07-28T11:57:57.909689', - 'title': 'Google News', - 'mtime': '2007-07-28T11:58:22.460331', - 'keep': '0', - 'icon-color': '#00EA11,#00588C', - 'activity': 'org.laptop.WebActivity', - 'mime_type': 'text/plain'} - -jsonData = '''{"history":[{"url":"http://www.google.com/","title":"Google"}, - {"url":"http://news.google.com/nwshp?tab=wn","title":"Google News"}]}''' - -uid = _data_store.create(props, '') -file_name = os.path.join('/tmp', str(time.time())) -fn = tmpData(jsonData) - -_data_store.update(uid, props, fn) - - - - -props = _data_store.get_properties(uid) -file_name = _data_store.get_filename(uid) -props['mountpoint'] = mount_id -# suggest a filename -props['filename'] = "history.json" -uid2 = _data_store.create(props, file_name) - -# the file name related to the new copy. -fn2 = _data_store.get_filename(uid2) - -assert fn2 - -contents = open(fn2, 'r').read() -assert contents == jsonData - -# Now unmount the store, remount it and read the file - -_data_store.unmount(mount_id) - - -mount_id = _data_store.mount('inplace:/tmp/store1', dict(title='pen drive')) - -fn2 = _data_store.get_filename(uid2) - -assert fn2 - -contents = open(fn2, 'r').read() -assert contents == jsonData - -print "ALL GOOD" - -print "Trying with Abidoc" - -props = {'mountpoint' : mount_id, - 'title' : 'Abidoc', - - } - -uid = _data_store.create(props, '') -# now update it with the document -fn = os.path.abspath("tests/test.odt") -abidoc = open(fn, 'r').read() - - -props['filename'] = 'test.odt' -_data_store.update(uid, props, fn) - -fn2 = _data_store.get_filename(uid) - -contents = open(fn2, 'r').read() -assert contents == abidoc - -print "Abiword ok" |