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-05-22 03:28:05 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-05-22 03:28:05 (GMT)
commitef6235dc7f019258893270e947b2b2f866fcb055 (patch)
treea9c96952c324a72d01571a936146d8b9ee721a60 /tests
parent99781fa78c5f694e0444ccd006446591cb4d919a (diff)
improved find api -- now returns [{p1}, {p2}], full_result_count
Diffstat (limited to 'tests')
-rw-r--r--tests/milestone_1.txt5
-rw-r--r--tests/query.txt36
-rw-r--r--tests/runalltests.py8
-rw-r--r--tests/sugar_demo_may17.txt5
4 files changed, 28 insertions, 26 deletions
diff --git a/tests/milestone_1.txt b/tests/milestone_1.txt
index 5a426c6..2c5cb83 100644
--- a/tests/milestone_1.txt
+++ b/tests/milestone_1.txt
@@ -32,12 +32,12 @@ 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.
->>> uids = ds.find()
+>>> results, count = ds.find()
A find command with out any parameters will return everything in the store.
* Get an object from the store given his uid.
->>> first_uid = uids[0].keys()[0]
+>>> first_uid = results[0]['uid']
>>> c1 = ds.get(first_uid)
* Get the object metadata.
@@ -77,6 +77,7 @@ We can also remove the file from the repository.
This is the basis of milestone 1.
+>>> ds.stop()
>>> del ds
diff --git a/tests/query.txt b/tests/query.txt
index eef2735..01ade71 100644
--- a/tests/query.txt
+++ b/tests/query.txt
@@ -24,7 +24,7 @@ Because this is a new database there should be nothing in it. We can
verify this with the call to the find() method.
>>> qm.find()
-[]
+([], 0)
The simplest way to add an entry to the datastore is by passing a
@@ -35,7 +35,7 @@ dictionary of properties to the create method.
Find will now return this object.
>>> qm.find()
-[<Content id:...>]
+([<Content id:...>], 1)
We can examine the Properties of this object.
@@ -102,7 +102,7 @@ modification time are supported. To query on these properties two
methods are available.
>>> qm.find(ctime="2007-01-01 00:00")
-[]
+([], 0)
Which matches nothing. And the other form is to pass a dict with
'start' and 'end' range boundries.
@@ -110,7 +110,7 @@ Which matches nothing. And the other form is to pass a dict with
>>> now = datetime.datetime.now().isoformat()
>>> qm.find(ctime=dict(end=now))
-[<Content id:...>]
+([<Content id:...>], 1)
Property keys are unique per Content item. This means that adding a
@@ -160,16 +160,16 @@ content in the datastore.
For now we are only interested in the properties.
->>> qm.find(mime_type="image/png") == [b]
+>>> qm.find(mime_type="image/png") == ([b], 1)
True
->>> qm.find(author="Benjamin") == [a]
+>>> qm.find(author="Benjamin") == ([a],1)
True
->>> qm.find(author="Sarah") == [b, c]
+>>> qm.find(author="Sarah") == ([b, c],2)
True
->>> qm.find(author="Sarah", mime_type="audio/mp3") == [c]
+>>> qm.find(author="Sarah", mime_type="audio/mp3") == ([c], 1)
True
Passing the special value, 'content' to find will pass an expression
@@ -181,16 +181,16 @@ understood by the index.
>>> from StringIO import StringIO
>>> qm.fulltext_index(a, StringIO("this is my content, hear it roar"))
->>> qm.find(fulltext="roar") == [a]
+>>> qm.find(fulltext="roar") == ([a], 1)
True
Combining this with properties also works.
->>> qm.find(fulltext="roar", author="Benjamin") == [a]
+>>> qm.find(fulltext="roar", author="Benjamin") == ([a], 1)
True
And we can verify the negitive as well.
>>> qm.find(fulltext="roar", author="Sarah")
-[]
+([], 0)
Calls to update() and create() both take an optional file argument
which will update the fulltext indexed content with the new value of
@@ -199,35 +199,35 @@ file.
>>> qm.update(a, file=StringIO("different text"))
The new content will be found
->>> qm.find(fulltext="different", author="Benjamin") == [a]
+>>> qm.find(fulltext="different", author="Benjamin") == ([a], 1)
True
And the old content is not.
>>> qm.find(fulltext="roar", author="Benjamin")
-[]
+([], 0)
Passing a filename for file works as well. Files can be in a variety
of binary formats include PDF.
>>> qm.update(a, file="test.doc")
>>> qm.find(fulltext="roar", author="Benjamin")
-[]
->>> qm.find(fulltext="amazed", author="Benjamin") == [a]
+([], 0)
+>>> qm.find(fulltext="amazed", author="Benjamin") == ([a], 1)
True
We have converters for DOC, PDF and ODT by default
>>> qm.update(a, file="test.pdf")
->>> qm.find(fulltext="peek", author="Benjamin") == [a]
+>>> qm.find(fulltext="peek", author="Benjamin") == ([a], 1)
True
>>> qm.update(a, file="test.odt")
->>> qm.find(fulltext="amazed", author="Benjamin") == [a]
+>>> qm.find(fulltext="amazed", author="Benjamin") == ([a], 1)
True
>>> qm.update(a, file="test.doc")
->>> qm.find(fulltext="amazed", author="Benjamin") == [a]
+>>> qm.find(fulltext="amazed", author="Benjamin") == ([a], 1)
True
diff --git a/tests/runalltests.py b/tests/runalltests.py
index dd179b7..e0a73e3 100644
--- a/tests/runalltests.py
+++ b/tests/runalltests.py
@@ -18,12 +18,14 @@ from sqlalchemy import clear_mappers
doctests = [
resource_filename(__name__, "query.txt"),
-# resource_filename(__name__, "milestone_1.txt"),
- resource_filename(__name__, "sugar_demo_may17.txt")
+ resource_filename(__name__, "milestone_1.txt"),
+ resource_filename(__name__, "sugar_demo_may17.txt"),
+ resource_filename(__name__, "milestone_2.txt")
+
]
doctest_options = doctest.ELLIPSIS
-#doctest_options |= doctest.REPORT_ONLY_FIRST_FAILURE
+doctest_options |= doctest.REPORT_ONLY_FIRST_FAILURE
# IF YOU ARE NOT GETTING THE RESULTS YOU EXPECT WHILE TESTING
diff --git a/tests/sugar_demo_may17.txt b/tests/sugar_demo_may17.txt
index 0f8cd94..1b2dea4 100644
--- a/tests/sugar_demo_may17.txt
+++ b/tests/sugar_demo_may17.txt
@@ -42,8 +42,7 @@ And retrieve again:
Get all entries (only have one):
>>> results, count = ds.find({})
->>> for uid, properties in results.iteritems():
-... properties['title']
+>>> results[0]['title']
'Same entry with some other content'
Check content:
@@ -58,5 +57,5 @@ Set content as 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.stop()
>>> del ds