Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile27
-rw-r--r--tests/__init__.py3
-rwxr-xr-xtests/cleaner.py40
-rw-r--r--tests/dateranges.txt42
-rw-r--r--tests/funkyabi.odtbin2603 -> 0 bytes
-rw-r--r--tests/milestone_1.txt89
-rw-r--r--tests/milestone_2.txt42
-rw-r--r--tests/mountpoints.txt217
-rw-r--r--tests/plugger.pdfbin17681 -> 0 bytes
-rw-r--r--tests/properties.txt47
-rw-r--r--tests/runalltests.py63
-rw-r--r--tests/sugar_demo_may17.txt72
-rw-r--r--tests/test.docbin103936 -> 0 bytes
-rw-r--r--tests/test.jpgbin985 -> 0 bytes
-rw-r--r--tests/test.odtbin6851 -> 0 bytes
-rw-r--r--tests/test.pdfbin144785 -> 0 bytes
-rw-r--r--tests/test_backingstore.py61
-rw-r--r--tests/test_conversion.py30
-rw-r--r--tests/test_model.py147
-rw-r--r--tests/test_xapianindex.py89
-rw-r--r--tests/testutils.py10
-rw-r--r--tests/web_data.json1
-rw-r--r--tests/xapianindex.txt90
23 files changed, 0 insertions, 1070 deletions
diff --git a/tests/Makefile b/tests/Makefile
deleted file mode 100644
index c2581cb..0000000
--- a/tests/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-# howto inherit this properly from above?
-# its not an option to configure
-PYTHON=python
-
-all: clean test
-
-test:
- @${PYTHON} runalltests.py
-
-valgrind:
- @echo "Profiling the process. Run kcachegrind on the output"
- valgrind --tool=callgrind --suppressions=valgrind-python.supp ${PYTHON} runalltests.py
-
-profile:
- @find . -name "hotspot*" -exec rm {} \;
- @${PYTHON} ./profilealltests.py
-
-clean:
- @${PYTHON} ./cleaner.py
- @find . -name "*.pyc" -exec rm {} \;
- @find . -name "*~" -exec rm {} \;
- @find . -name "hotspot*" -exec rm {} \;
- @find . -name "callgrind.out*" -exec rm {} \;
-
-tags:
-
-
diff --git a/tests/__init__.py b/tests/__init__.py
deleted file mode 100644
index 6f73726..0000000
--- a/tests/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# testing package
-
-
diff --git a/tests/cleaner.py b/tests/cleaner.py
deleted file mode 100755
index cfa15bf..0000000
--- a/tests/cleaner.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/python
-import os
-import re
-from ore.main import Application
-
-filepattern = re.compile("(\w{8})\-(\w{4})\-(\w{4})\-(\w{4})\-(\w{12})")
-tmppattern = re.compile("tmp\S{6}")
-onepattern = re.compile("one.*\.txt")
-
-staticdirs = re.compile('test_ds|store\d')
-
-filepatterns = [filepattern, tmppattern, onepattern]
-dirpatterns = [staticdirs]
-
-class Cleaner(Application):
- def manage_options(self):
- self.parser.add_option("--base", dest="base_dir",
- action="store", default='/tmp',
- help="""Where to clean (/tmp)""")
-
- def main(self):
- """clean up files left from testing in /tmp"""
- # this is done using patterned names
- for root, dirs, files in os.walk(self.options.base_dir):
- for filename in files:
- for pat in filepatterns:
- if pat.match(filename):
- fn = os.path.join(root, filename)
- os.remove(fn)
- break
- for dirname in dirs:
- for pat in dirpatterns:
- if pat.match(dirname):
- dn = os.path.join(root, dirname)
- os.system('rm -rf %s' % dn)
-
-if __name__ == "__main__":
- Cleaner("cleaner")()
-
-
diff --git a/tests/dateranges.txt b/tests/dateranges.txt
deleted file mode 100644
index 886e7d2..0000000
--- a/tests/dateranges.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Test that date
-First clean up from any other tests.
->>> import os, datetime
->>> assert os.system('rm -rf /tmp/test_ds/') == 0
-
->>> from olpc.datastore import DataStore
->>> from olpc.datastore import backingstore, model
->>> ds = DataStore()
->>> ds.registerBackend(backingstore.FileBackingStore)
-
->>> assert ds.mount("/tmp/test_ds")
-
->>> t1 = datetime.datetime(1995, 1, 1)
->>> t2 = datetime.datetime(2000, 1, 1)
->>> t3 = datetime.datetime(2005, 1, 1)
-
->>> a = ds.create(dict(title="Content A", author="Bob", ctime=t1.isoformat()), '')
->>> b = ds.create(dict(title="Content B", author="Alice", ctime=t2.isoformat()), '')
->>> c = ds.create(dict(title="Content V", author="Clare", ctime=t3.isoformat()), '')
-
->>> ds.complete_indexing()
-
-
-Scan for ranges
-
->>> result, count = ds.find({'ctime' : {'start' : t1.isoformat(), 'end' : t3.isoformat() }})
->>> assert count == 3
-
-
->>> result, count = ds.find({'ctime' : {'start' : t1.isoformat(), 'end' : t2.isoformat() }})
->>> assert count == 2
-
->>> result, count = ds.find({'ctime' : {'start' : t2.isoformat(), 'end' : t3.isoformat() }})
->>> assert count == 2
-
->>> result, count = ds.find({'ctime' : {'start' : t1.isoformat(), 'end' : t1.isoformat() }})
->>> assert count == 1
-
-
->>> ds.stop()
->>> del ds
->>> assert os.system('rm -rf /tmp/test_ds/') == 0
diff --git a/tests/funkyabi.odt b/tests/funkyabi.odt
deleted file mode 100644
index 1850b47..0000000
--- a/tests/funkyabi.odt
+++ /dev/null
Binary files differ
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
diff --git a/tests/milestone_2.txt b/tests/milestone_2.txt
deleted file mode 100644
index 551e1e3..0000000
--- a/tests/milestone_2.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Once the datastore is running its important to be able to sort the
-results along the lines of various criteria. Lets create a sample
-datastore.
-
-First clean up from any other tests.
->>> import os
->>> assert os.system('rm -rf /tmp/test_ds/') == 0
-
->>> from olpc.datastore import DataStore
->>> from olpc.datastore import backingstore, model
->>> ds = DataStore()
->>> ds.registerBackend(backingstore.FileBackingStore)
-
->>> assert ds.mount("/tmp/test_ds")
-
->>> 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]]
-
->>> ds.complete_indexing()
-
->>> assert set(find2uids(ds.find())) == set([a,b])
-
-
-But what if we want the results ordered?
->>> assert find2uids(ds.find(order_by=['title'])) == [a, b]
->>> assert find2uids(ds.find(order_by=['author'])) == [b, a]
-
-By more than one key?
-
->>> assert find2uids(ds.find(order_by=['month', 'year'])) == [a, b]
-
-and if we want to reverse order it?
-
->>> assert find2uids(ds.find(order_by=['-title'])) == [b, a]
->>> assert find2uids(ds.find(order_by=['-author'])) == [a, b]
-
->>> ds.stop()
->>> del ds
->>> assert os.system('rm -rf /tmp/test_ds/') == 0
diff --git a/tests/mountpoints.txt b/tests/mountpoints.txt
deleted file mode 100644
index 695e7d2..0000000
--- a/tests/mountpoints.txt
+++ /dev/null
@@ -1,217 +0,0 @@
-Mountpoints are very much like traditional *NIX filesystem mounts. The
-intention is to allow more than one backingstore (stable storage
-device) to become part of a datastore at runtime. This is done by
-mounting a backingstore on the datastore.
-
-(clean up)
->>> import os
->>> assert os.system('rm -rf /tmp/store1/') == 0
->>> assert os.system('rm -rf /tmp/store2/') == 0
->>> assert os.system('rm -rf /tmp/store3/') == 0
-
-
->>> from olpc.datastore import DataStore
->>> from olpc.datastore import backingstore
->>> from testutils import tmpData
->>> import dbus
-
-
-Here we create a datastore, and mount a backingstore on tmp. By
-default this will create a new directory in /tmp which will then be
-used for storage.
-
->>> ds = DataStore()
->>> ds.registerBackend(backingstore.FileBackingStore)
->>> mp1 = ds.mount("/tmp/store1", dict(title="Primary Storage"))
-
-This will list all the mount points. It returns a list of dicts with
-the minumum keyset of 'id', 'uri', and 'title'. Title is the Human
-readable name of the mount. 'Id' is the most important property this
-can be used to control the storage target or to filter results.
-
->>> mps = ds.mounts()
->>> mountpoint = mps[0]['id']
-
-
-Now lets create some content
-
->>> u1 = ds.create(dict(title="Document 1", filename="one.txt"), tmpData("""document one"""))
->>> u2 = ds.create(dict(title="Document 2", mime_type="text/plain"), tmpData("""document two"""))
-
-We can now, if we wish verify which mount point this content came
-from.
-
->>> ds.complete_indexing()
-
->>> c1 = ds.get(u1)
->>> assert c1.backingstore.id == mountpoint
-
-However this interface isn't available over DBus and objects are
-normally located and inspected using the find() method.
-
->>> c1a = ds.find(dict(title="Document 1"))[0][0]
->>> assert c1a['mountpoint'] == mountpoint
-
-We can see that the mountpoint property was mapped on the object and
-refers to the proper storage.
-
-Now lets add another mount point.
-
->>> mp2 = ds.mount("/tmp/store2", dict(title="Secondary Storage"))
-
-Now lets create a new content item.
->>> u3 = ds.create(dict(title="Document 3", mountpoint=mp2), tmpData("""document three"""))
-
->>> ds.complete_indexing()
-
-We explictly passed a mount point here. Lets examine the properties of
-the object and verify this.
->>> c3 = ds.find(dict(title="Document 3"))[0][0]
->>> assert c3['mountpoint'] == mp2
-
-Now lets filter a find call to only selected mountpoints.
-
->>> results, count = ds.find(dict(mountpoints=[mp1]))
->>> assert count == 2
-
->>> results, count = ds.find(dict(mountpoints=[mp2]))
->>> assert count == 1
-
->>> results, count = ds.find({})
->>> assert count == 3
-
-We can see that filtering by mount point works as expected.
-
-Now we are going to create an inplace mount. This is designed around
-USB keys and the like. In this case we want to leave files in place,
-there will be no working copies.
-
-First lets create some inplace data that we expect to get imported and
-indexed.
-
->>> os.makedirs("/tmp/store3/nested")
->>> fp = open("/tmp/store3/doc4.txt", "w")
->>> fp.write("This is document four")
->>> fp.close()
-
->>> fp = open("/tmp/store3/nested/doc5.txt", "w")
->>> fp.write("This is document five")
->>> fp.close()
-
-Register the filesystem type
->>> ds.registerBackend(backingstore.InplaceFileBackingStore)
-
->>> mp3 = ds.mount("inplace:/tmp/store3", dict(title="Fake USB"))
-
-If that worked it should have imported content on load().
-
->>> ds.complete_indexing()
-
->>> result, count = ds.find(dict(fulltext="four"))
->>> assert count == 1
->>> assert result[0]['mountpoint'] == mp3
-
-
-Let's unmount 'Fake USB' and then remount it with some options passed
-as DBus data.
-
->>> ds.unmount(mp3)
-
->>> mp3 = ds.mount("inplace:/tmp/store3", dict(title=dbus.String("Fake USB again"),
-... sync_mount=True))
-
->>> ds.complete_indexing()
-
-
->>> result, count = ds.find(dict(fulltext="four"))
->>> assert count == 1
->>> assert result[0]['mountpoint'] == mp3
-
->>> mp = ds.mountpoints[mp3]
-
-Check for the new value in the descriptor
-
->>> assert mp.descriptor()['title'] == 'Fake USB again'
-
-Verify that we can get the properties of objects on the inplace
-stores.
-
->>> uid = result[0]['uid']
->>> props = ds.get_properties(uid)
->>> assert props['title'] == "doc4"
-
-
-Currently sugar defines doing a copy as zeroing out the uid and
-changing the mountpoint. Lets copy an object from mp3 to mp1, the
-primary store.
->>> props['mountpoint'] = mountpoint
->>> fn = ds.get_filename(uid)
-
->>> copyuid = ds.create(props, fn)
-
->>> ds.complete_indexing()
-
-
->>> result, count = ds.find(dict(fulltext="four"))
->>> assert count == 2
-
-We also need to test that we can copy from a normal store to an
-inplace one. Lets move the object with u1 to mp3
-
->>> props = ds.get_properties(u1)
->>> props['mountpoint'] = mp3
->>> pen_copy = ds.create(props, ds.get_filename(u1))
-
->>> ds.complete_indexing()
-
->>> result, count = ds.find(dict(mountpoints=[mp3], filename="one.txt"))
->>> 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')
-
-Now let's update that file.
-
->>> fn = ds.get_filename(u1)
->>> fp = open(fn, 'w')
->>> print >>fp, "This is new content"
->>> fp.close()
-
->>> ds.update(pen_copy, props, fn)
->>> ds.complete_indexing()
-
-and verify it worked.
-
->>> result, count = ds.find(dict(query="new content"))
->>> assert count == 1
->>> assert result[0]['uid'] == pen_copy
-
-
-
-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/plugger.pdf b/tests/plugger.pdf
deleted file mode 100644
index 737dab2..0000000
--- a/tests/plugger.pdf
+++ /dev/null
Binary files differ
diff --git a/tests/properties.txt b/tests/properties.txt
deleted file mode 100644
index 6c3c91b..0000000
--- a/tests/properties.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-This document shows off the range of features available for attaching
-properties to content and managing them.
-
-(clean up)
->>> import os
->>> assert os.system('rm -rf /tmp/store1/') == 0
->>> assert os.system('rm -rf /tmp/store2/') == 0
-
-
->>> from olpc.datastore import DataStore
->>> from olpc.datastore import backingstore, model
->>> from testutils import tmpData
->>> import dbus
-
-Set up two mount points.
-
->>> ds = DataStore()
->>> ds.registerBackend(backingstore.FileBackingStore)
-
-Extend the model to retain a 'year' property used below.
-
-Mount a couple of stores.
-
->>> 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: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: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()
-
-Here we test that we can extract the unique values for certain properties.
->>> assert set(ds.get_uniquevaluesfor('author')) == set(['Ben', 'HAL'])
-
-Here we try to gather the values for the property year.
-
->>> assert set(ds.get_uniquevaluesfor('year')) == set([2000, 2001])
-
-
-
->>> ds.stop(); del ds
diff --git a/tests/runalltests.py b/tests/runalltests.py
deleted file mode 100644
index 8fee87e..0000000
--- a/tests/runalltests.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/python
-#
-# Runs all tests in the current directory
-#
-# Execute like:
-# python runalltests.py
-#
-# Alternatively use the testrunner:
-# python /path/to/Zope/utilities/testrunner.py -qa
-#
-import os, sys
-import unittest
-import doctest
-from pkg_resources import resource_filename
-import logging
-
-logging.basicConfig(level=logging.WARN,
- format="%(asctime)-15s %(name)s %(levelname)s: %(message)s",
- stream=sys.stderr)
-
-
-doctests = [
- resource_filename(__name__, "xapianindex.txt"),
- resource_filename(__name__, "milestone_1.txt"),
- resource_filename(__name__, "sugar_demo_may17.txt"),
- resource_filename(__name__, "milestone_2.txt"),
- resource_filename(__name__, "mountpoints.txt"),
- resource_filename(__name__, "properties.txt"),
- resource_filename(__name__, "dateranges.txt"),
-
-]
-
-doctest_options = doctest.ELLIPSIS
-#doctest_options |= doctest.REPORT_ONLY_FIRST_FAILURE
-
-
-def test_suite():
- global doctests
- suite = unittest.TestSuite()
- if len(sys.argv) > 1:
- doctests = sys.argv[1:]
-
- for dt in doctests:
- suite.addTest(doctest.DocFileSuite(dt,
- optionflags=doctest_options))
-
- if len(sys.argv) <= 1:
- tests = os.listdir(os.curdir)
- tests = [n[:-3] for n in tests if n.startswith('test') and
- n.endswith('.py')]
-
- for test in tests:
- m = __import__(test)
- if hasattr(m, 'test_suite'):
- suite.addTest(m.test_suite())
- return suite
-
-
-if __name__ == "__main__":
- runner = unittest.TextTestRunner(verbosity=1)
- suite = test_suite()
- runner.run(suite)
-
diff --git a/tests/sugar_demo_may17.txt b/tests/sugar_demo_may17.txt
deleted file mode 100644
index 64d49e5..0000000
--- a/tests/sugar_demo_may17.txt
+++ /dev/null
@@ -1,72 +0,0 @@
-How Sugar will interact with the DS for the May 17th demo in Argentina:
-
->>> from olpc.datastore import DataStore
->>> from olpc.datastore import backingstore
->>> ds = DataStore()
->>> ds.registerBackend(backingstore.FileBackingStore)
->>> assert ds.mount("/tmp/test_ds")
-
-
-Create an entry without data:
->>> uid = ds.create(dict(title="New entry"), '')
->>> ds.complete_indexing()
-
->>> ds.get_filename(uid)
-''
-
-Update an entry without data:
->>> ds.update(uid, dict(title="New entry still without content"), '')
-
->>> ds.complete_indexing()
-
->>> ds.get_filename(uid)
-''
-
-Add some data to the same entry:
->>> fp = open('/tmp/sugar_ds_test', 'w')
->>> print >>fp, "some content"
->>> fp.close()
->>> ds.update(uid, dict(title="Same entry now with some content"), fp.name)
->>> ds.complete_indexing()
-
-Retrieve that data:
->>> fn = ds.get_filename(uid)
->>> fp = open(fn, 'r')
->>> fp.read()
-'some content\n'
->>> fp.close()
-
-Update again:
->>> fp = open('/tmp/sugar_ds_test2', 'w')
->>> print >>fp, "some other content"
->>> fp.close()
->>> ds.update(uid, dict(title="Same entry with some other content"), fp.name)
->>> ds.complete_indexing()
-
-And retrieve again:
->>> fn = ds.get_filename(uid)
->>> fp = open(fn, 'r')
->>> fp.read()
-'some other content\n'
->>> fp.close()
-
-Get all entries (only have one):
->>> results, count = ds.find({})
->>> results[0]['title']
-'Same entry with some other content'
-
-Check content:
->>> fn = ds.get_filename(uid)
->>> fp = open(fn, 'r')
->>> fp.read()
-'some other content\n'
->>> fp.close()
-
-Set content as pdf:
->>> ds.update(uid, dict(title="Same entry with some content in pdf"), 'test.pdf')
->>> ds.update(uid, dict(title="Same entry with some content in doc"), 'test.doc')
->>> ds.update(uid, dict(title="Same entry with some content in odt"), 'test.odt')
->>> ds.complete_indexing()
-
->>> ds.stop()
->>> del ds
diff --git a/tests/test.doc b/tests/test.doc
deleted file mode 100644
index 354e2ab..0000000
--- a/tests/test.doc
+++ /dev/null
Binary files differ
diff --git a/tests/test.jpg b/tests/test.jpg
deleted file mode 100644
index d7f330b..0000000
--- a/tests/test.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/test.odt b/tests/test.odt
deleted file mode 100644
index a8594a4..0000000
--- a/tests/test.odt
+++ /dev/null
Binary files differ
diff --git a/tests/test.pdf b/tests/test.pdf
deleted file mode 100644
index 3478a64..0000000
--- a/tests/test.pdf
+++ /dev/null
Binary files differ
diff --git a/tests/test_backingstore.py b/tests/test_backingstore.py
deleted file mode 100644
index 4138219..0000000
--- a/tests/test_backingstore.py
+++ /dev/null
@@ -1,61 +0,0 @@
-import unittest
-from testutils import tmpData
-
-from olpc.datastore import backingstore
-import os
-
-DEFAULT_STORE = '/tmp/_bs_test'
-
-class Test(unittest.TestCase):
- def setUp(self):
- if os.path.exists(DEFAULT_STORE):
- os.system("rm -rf %s" % DEFAULT_STORE)
-
- 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 'uri' in desc
- assert 'title' in desc
- assert desc['title'] is not None
-
- d = """This is a test"""
- d2 = "Different"
-
- uid = bs.create(dict(title="A"), tmpData(d))
-
- bs.complete_indexing()
-
- obj = bs.get(uid)
-
- assert obj.get_property('title') == "A"
- got = obj.file.read()
- assert got == d
-
- bs.update(uid, dict(title="B"), tmpData(d2))
-
- bs.complete_indexing()
-
- obj = bs.get(uid)
- assert obj.get_property('title') == "B"
- got = obj.file.read()
- assert got == d2
-
- bs.delete(uid)
- bs.complete_indexing()
- self.failUnlessRaises(KeyError, bs.get, uid)
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Test))
- return suite
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/tests/test_conversion.py b/tests/test_conversion.py
deleted file mode 100644
index aa6f1a9..0000000
--- a/tests/test_conversion.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import unittest
-
-from olpc.datastore.converter import converter
-from StringIO import StringIO
-
-class Test(unittest.TestCase):
-
- def test_unicode(self):
- # read each of the test files in doing conversion,
- # there should be no unicode errors
- fn_expectations = {
- 'test.pdf' : 'Don\'t',
- 'test.doc' : 'amazed.',
- 'test.odt' : 'amazed.',
- 'plugger.pdf' : 'Plugger',
- 'funkyabi.odt' : 'vaca'
- }
- for fn, expect in fn_expectations.iteritems():
- assert expect in converter(fn).read()
-
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Test))
- return suite
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/tests/test_model.py b/tests/test_model.py
deleted file mode 100644
index 6d171c1..0000000
--- a/tests/test_model.py
+++ /dev/null
@@ -1,147 +0,0 @@
-import unittest
-from testutils import tmpData
-
-from olpc.datastore import DataStore
-from olpc.datastore import model, backingstore
-import datetime
-import os
-
-
-DEFAULT_STORE = '/tmp/test_ds'
-
-class Test(unittest.TestCase):
- def setUp(self): os.system('rm -rf %s' % DEFAULT_STORE)
- def tearDown(self): os.system('rm -rf %s' % DEFAULT_STORE)
-
- def test_dateproperty(self):
- n = datetime.datetime.now()
- # we have to kill the microseconds as
- # time.strptime which we must use in 2.4 doesn't parse it
- n = n.replace(microsecond=0)
- p = model.Property('ctime', n.isoformat(), 'date')
- assert p.key == "ctime"
- assert p.value == n.isoformat()
- p.value = p.value
- assert p.value == n.isoformat()
-
- def test_binaryproperty(self):
- ds = DataStore()
- ds.registerBackend(backingstore.FileBackingStore)
-
-
- 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:binary' : data, 'ctime' : n.isoformat()}, fn)
-
- ds.complete_indexing()
-
- c = ds.get(uid)
- assert c.get_property('thumbnail') == data
- # I don't care about the microsecond issue now, the typelib
- # patch later can fix that
- assert c.get_property('ctime')[:19] == n.isoformat()[:19]
-
- ds.stop()
-
-
- def test_intproperty(self):
- p = model.Property('keep', 1, 'int')
- assert p.value == '1'
-
- p.value = 0
- assert p.value == '0'
-
- p.value = '1'
- assert p.value == '1'
-
- p.value = '0'
- assert p.value == '0'
-
-
- ds = DataStore()
- ds.registerBackend(backingstore.FileBackingStore)
-
- ds.mount(DEFAULT_STORE)
-
- uid = ds.create({'title' : "Document 1", 'keep' : 1},)
- ds.complete_indexing()
- c = ds.get(uid)
- assert c.get_property('keep') == 1
-
- ds.update(uid, {'title' : "Document 1", 'keep' : 0})
- ds.complete_indexing()
- c = ds.get(uid)
- assert c.get_property('keep') == 0
-
-
- ds.update(uid, {'title' : "Document 1", 'keep' : '1'})
- ds.complete_indexing()
- c = ds.get(uid)
- assert c.get_property('keep') == 1
-
- ds.update(uid, {'title' : "Document 1", 'keep' : '0'})
- ds.complete_indexing()
- c = ds.get(uid)
- assert c.get_property('keep') == 0
-
- ds.stop()
-
- def test_randomproperty(self):
- # specifying items not in the model, with and w/o type
- # qualifiers
- ds = DataStore()
- ds.registerBackend(backingstore.FileBackingStore)
-
- ds.mount(DEFAULT_STORE)
-
- uid = ds.create({'title' : 'Random Extras', 'foobar' : 'baz',
- 'incept:date' : datetime.datetime.now().isoformat()})
-
- ds.complete_indexing()
-
- ds.update(uid, {'title' : 'Random Extras the sequel',
- 'foobar' : 'whodofoodo',
- 'incept:date' : datetime.datetime.now().isoformat()})
-
- ds.complete_indexing()
-
- # ignored w/o prefix
- assert ds.find('whodofoodo')[1] == 0
- # found with it
- assert ds.find('foobar:whodofoodo')[1] == 1
- c = ds.get_properties(uid)
- assert 'foobar' in c
- assert 'title' in c
- # maps back w/o the type
- assert 'incept' in c
-
- ds.update(uid, {'title' : 'Random Extras the sequel',
- 'foobar' : '',
- 'incept:date' : datetime.datetime.now().isoformat()})
-
- ds.complete_indexing()
- assert ds.find('whodofoodo')[1] == 0
- # found with it
- assert ds.find('foobar:whodofoodo')[1] == 0
- c = ds.get_properties(uid)
- assert 'title' in c
- # maps back w/o the type
- assert 'incept' in c
- assert c['foobar'] == ''
-
-
- ds.stop()
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Test))
- return suite
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/tests/test_xapianindex.py b/tests/test_xapianindex.py
deleted file mode 100644
index c455c44..0000000
--- a/tests/test_xapianindex.py
+++ /dev/null
@@ -1,89 +0,0 @@
-from olpc.datastore.xapianindex import IndexManager
-import os
-from datetime import datetime
-
-import time
-import unittest
-import gnomevfs
-
-DEFAULT_STORE = '/tmp/_xi_test'
-
-
-def index_file(iconn, filepath):
- """Index a file."""
-
- mimetype = gnomevfs.get_mime_type(filepath)
- main, subtype = mimetype.split('/',1)
-
- stat = os.stat(filepath)
- ctime = datetime.fromtimestamp(stat.st_ctime).isoformat()
- mtime = datetime.fromtimestamp(stat.st_mtime).isoformat()
-
- if main in ['image']: filepath = None
- if subtype in ['x-trash', 'x-python-bytecode']: filepath = None
-
-
-
- props = {'mime_type' : mimetype, 'mtime' : mtime, 'ctime' : ctime,}
-
- if filepath:
- fn = os.path.split(filepath)[1]
- props['filename'] = fn
-
- iconn.index(props, filepath)
-
- return 1
-
-def index_path(iconn, docpath):
- """Index a path."""
- count = 0
- for dirpath, dirnames, filenames in os.walk(docpath):
- for filename in filenames:
- filepath = os.path.join(dirpath, filename)
- index_file(iconn, filepath)
- count += 1
- return count
-
-class Test(unittest.TestCase):
- def setUp(self):
- if os.path.exists(DEFAULT_STORE):
- os.system("rm -rf %s" % DEFAULT_STORE)
-
- def tearDown(self):
- if os.path.exists(DEFAULT_STORE):
- os.system("rm -rf %s" % DEFAULT_STORE)
-
- def test_index(self):
- # import a bunch of documents into the store
- im = IndexManager()
- im.connect(DEFAULT_STORE)
-
- # test basic index performance
- start = time.time()
- count = index_path(im, os.getcwd())
- end = time.time()
- delta = end - start
-
- #print "%s in %s %s/sec" % (count, delta, count/delta)
-
- # wait for indexing to finish
- im.complete_indexing()
-
- # test basic search performance
- results = list(im.search('peek')[0])
-
- # this indicates that we found text inside binary content that
- # we expected
- assert 'test.pdf' in set(r.get_property('filename') for r in results)
-
- assert im.search('mime_type:application/pdf filename:test.pdf peek')[1] == 1
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(Test))
- return suite
-
-if __name__ == "__main__":
- unittest.main()
-
diff --git a/tests/testutils.py b/tests/testutils.py
deleted file mode 100644
index fc667db..0000000
--- a/tests/testutils.py
+++ /dev/null
@@ -1,10 +0,0 @@
-import tempfile
-import os
-
-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
-
diff --git a/tests/web_data.json b/tests/web_data.json
deleted file mode 100644
index bfd983b..0000000
--- a/tests/web_data.json
+++ /dev/null
@@ -1 +0,0 @@
-{"history":[{"url":"http://www.google.com/","title":"Google"}]} \ No newline at end of file
diff --git a/tests/xapianindex.txt b/tests/xapianindex.txt
deleted file mode 100644
index 22aa05d..0000000
--- a/tests/xapianindex.txt
+++ /dev/null
@@ -1,90 +0,0 @@
-The xapian index module can be used directly as follows
-
-First clean up any old test data.
-
->>> index_home = "/tmp/xi"
->>> import os, sys, time, logging
->>> assert os.system('rm -rf %s' % index_home) == 0
-
-# >>> logging.basicConfig(level=logging.DEBUG,
-# ... format="%(asctime)-15s %(name)s %(levelname)s: %(message)s",
-# ... stream=sys.stderr)
-
-
->>> from olpc.datastore.xapianindex import IndexManager
->>> from olpc.datastore import model
->>> im = IndexManager()
->>> im.connect(index_home)
-
-
-Now add the file to the index.
-
->>> props = dict(title="PDF Document",
-... mime_type="application/pdf")
-
-
->>> uid = im.index(props, "test.pdf")
-
-Let the async indexer do its thing. We ask the indexer if it has work
-left, when it has none we expect our content to be indexed and searchable.
-
->>> im.complete_indexing()
-
-
-Searching on an property of the content works.
->>> def expect(r, count=None):
-... if count: assert r[1] == count
-... return list(r[0])
->>> def expect_single(r):
-... assert r[1] == 1
-... return r[0].next()
->>> def expect_none(r):
-... assert r[1] == 0
-... assert list(r[0]) == []
-
-
->>> assert expect_single(im.search("PDF")).id == uid
-
-Searching into the binary content of the object works as well.
->>> assert expect_single(im.search("peek")).id == uid
-
-Specifying a search that demands a document term be found only in the
-title works as well.
-
->>> assert expect_single(im.search('title:PDF')).id == uid
->>> expect_none(im.search('title:peek'))
-
-Searching for documents that are PDF works as expected here. Here we
-use the dictionary form of the query where each field name is given
-and creates a search.
->>> assert expect_single(im.search(dict(mime_type='application/pdf'))).id == uid
-
-Punctuation is fine.
-
->>> assert expect_single(im.search("Don't peek")).id == uid
-
-As well as quoted strings
-
->>> assert expect_single(im.search(r'''"Don't peek"''')).id == uid
-
-
-We can also issue OR styled queries over a given field by submitting
-a list of queries to a given field.
-
->>> assert expect_single(im.search(dict(mime_type=["text/plain",
-... 'application/pdf']))).id == uid
-
-
-But an OR query for missing values still return nothing.
-
->>> expect_none(im.search(dict(mime_type=["video/mpg",
-... 'audio/ogg'])))
-
-
-
-
-
-Cleanly shut down.
->>> im.stop()
-
->>> assert os.system('rm -rf %s' % index_home) == 0