You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2015/02/03 16:13:10 UTC

[03/50] [abbrv] couchdb-mango git commit: Minor test case fixes

Minor test case fixes

A minor race condition in recreating the database would lead to
occasional 500's when cycling the test db. I also added a deep copy in
user_docs.py or else the _revs would exist on the second test which
generated conflicts.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/29dc32c3
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/29dc32c3
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/29dc32c3

Branch: refs/heads/master
Commit: 29dc32c3fd522feda577ccad58723d487b0e9d06
Parents: 2744ddf
Author: Paul J. Davis <pa...@gmail.com>
Authored: Tue Jun 24 15:08:26 2014 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Tue Jun 24 15:08:26 2014 -0500

----------------------------------------------------------------------
 test/04-empty-selectors-test.py | 36 ++++++++++++++++++++++++++++++++++++
 test/04-empty-selectors.py      | 36 ------------------------------------
 test/mango.py                   |  3 +++
 test/user_docs.py               |  6 +++---
 4 files changed, 42 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/29dc32c3/test/04-empty-selectors-test.py
----------------------------------------------------------------------
diff --git a/test/04-empty-selectors-test.py b/test/04-empty-selectors-test.py
new file mode 100644
index 0000000..ba05ea3
--- /dev/null
+++ b/test/04-empty-selectors-test.py
@@ -0,0 +1,36 @@
+
+import user_docs
+
+
+def setup():
+    user_docs.create_db_and_indexes()
+
+
+def test_empty():
+    db = user_docs.mkdb()
+    try:
+        db.find({})
+    except Exception, e:
+        assert e.response.status_code == 400
+    else:
+        raise AssertionError("bad find")
+
+
+def test_empty_subsel():
+    db = user_docs.mkdb()
+    docs = db.find({
+            "_id": {"$gt": None},
+            "location": {}
+        })
+    assert len(docs) == 0
+
+
+def test_empty_subsel_match():
+    db = user_docs.mkdb()
+    db.save_docs([{"user_id": "eo", "empty_obj": {}}])
+    docs = db.find({
+            "_id": {"$gt": None},
+            "empty_obj": {}
+        })
+    assert len(docs) == 1
+    assert docs[0]["user_id"] == "eo"

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/29dc32c3/test/04-empty-selectors.py
----------------------------------------------------------------------
diff --git a/test/04-empty-selectors.py b/test/04-empty-selectors.py
deleted file mode 100644
index ba05ea3..0000000
--- a/test/04-empty-selectors.py
+++ /dev/null
@@ -1,36 +0,0 @@
-
-import user_docs
-
-
-def setup():
-    user_docs.create_db_and_indexes()
-
-
-def test_empty():
-    db = user_docs.mkdb()
-    try:
-        db.find({})
-    except Exception, e:
-        assert e.response.status_code == 400
-    else:
-        raise AssertionError("bad find")
-
-
-def test_empty_subsel():
-    db = user_docs.mkdb()
-    docs = db.find({
-            "_id": {"$gt": None},
-            "location": {}
-        })
-    assert len(docs) == 0
-
-
-def test_empty_subsel_match():
-    db = user_docs.mkdb()
-    db.save_docs([{"user_id": "eo", "empty_obj": {}}])
-    docs = db.find({
-            "_id": {"$gt": None},
-            "empty_obj": {}
-        })
-    assert len(docs) == 1
-    assert docs[0]["user_id"] == "eo"

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/29dc32c3/test/mango.py
----------------------------------------------------------------------
diff --git a/test/mango.py b/test/mango.py
index 92e99d8..92c2a2c 100644
--- a/test/mango.py
+++ b/test/mango.py
@@ -1,5 +1,6 @@
 
 import json
+import time
 
 import requests
 
@@ -34,7 +35,9 @@ class Database(object):
 
     def recreate(self):
         self.delete()
+        time.sleep(1)
         self.create()
+        time.sleep(1)
 
     def save_doc(self, doc):
         self.save_docs([doc])

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/29dc32c3/test/user_docs.py
----------------------------------------------------------------------
diff --git a/test/user_docs.py b/test/user_docs.py
index a108bf2..36f2d2d 100644
--- a/test/user_docs.py
+++ b/test/user_docs.py
@@ -37,6 +37,7 @@ With this pattern:
 ]
 """
 
+import copy
 import time
 
 import mango
@@ -49,8 +50,7 @@ def mkdb():
 def create_db_and_indexes():
     db = mkdb()
     db.recreate()
-    time.sleep(1)
-    db.save_docs(DOCS)
+    db.save_docs(copy.deepcopy(DOCS))
     indexes = [
         ["user_id"],
         ["name.last", "name.first"],
@@ -456,4 +456,4 @@ DOCS = [
             "Lisp"
         ]
     }
-]
\ No newline at end of file
+]