couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [35/50] [abbrv] couchdb-mango git commit: Move key tests to their own test suite
Date Tue, 03 Feb 2015 15:13:42 GMT
Move key tests to their own test suite


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

Branch: refs/heads/master
Commit: 08c33202ff848814ab4bab11d18284417ccd5bd2
Parents: 9ed1304
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Fri Jan 9 16:06:17 2015 -0600
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Fri Jan 16 13:32:49 2015 -0600

----------------------------------------------------------------------
 test/02-basic-find-test.py | 25 ----------------
 test/04-key-tests.py       | 65 +++++++++++++++++++++++++++++++++++++++++
 test/user_docs.py          | 28 +-----------------
 3 files changed, 66 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/08c33202/test/02-basic-find-test.py
----------------------------------------------------------------------
diff --git a/test/02-basic-find-test.py b/test/02-basic-find-test.py
index 58029ed..4e3fc29 100644
--- a/test/02-basic-find-test.py
+++ b/test/02-basic-find-test.py
@@ -235,31 +235,6 @@ class BasicFindTests(mango.UserDocsTests):
             docs = self.db.find({"age": {"$gt": 0}}, r=r)
             assert len(docs) == 15
 
-    def test_dot_key(self):
-        fields = ["title", "dot\\.key", "none.dot"]
-        docs = self.db.find({"type": "complex_key"}, fields = fields)
-        assert len(docs) == 4
-        assert docs[1].has_key("dot.key")
-        assert docs[1]["dot.key"] == "dot's value"
-        assert docs[1].has_key("none")
-        assert docs[1]["none"]["dot"] == "none dot's value"
-
-    def test_peso_key(self):
-        fields = ["title", "$key", "deep.$key"]
-        docs = self.db.find({"type": "complex_key"}, fields = fields)
-        assert len(docs) == 4
-        assert docs[2].has_key("$key")
-        assert docs[2]["$key"] == "peso"
-        assert docs[2].has_key("deep")
-        assert docs[2]["deep"]["$key"] == "deep peso"
-
-    def test_unicode_key(self):
-        docs = self.db.find({"type": "complex_key"}, fields = ["title", ""])
-        assert len(docs) == 4
-        # note:  == \uf8ff
-        assert docs[3].has_key(u'\uf8ff')
-        assert docs[3][u'\uf8ff'] == "apple"
-
     def test_empty(self):
         try:
             self.db.find({})

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/08c33202/test/04-key-tests.py
----------------------------------------------------------------------
diff --git a/test/04-key-tests.py b/test/04-key-tests.py
new file mode 100644
index 0000000..4a5e904
--- /dev/null
+++ b/test/04-key-tests.py
@@ -0,0 +1,65 @@
+# -*- coding: utf-8 -*-
+
+import mango
+
+
+TEST_DOCS = [
+    {
+        "type": "complex_key",
+        "title": "normal key"
+    },
+    {
+        "type": "complex_key",
+        "title": "key with dot",
+        "dot.key": "dot's value",
+        "none": {
+            "dot": "none dot's value"
+        }
+    },
+    {
+        "type": "complex_key",
+        "title": "key with peso",
+        "$key": "peso",
+        "deep": {
+            "$key": "deep peso"
+        }
+    },
+    {
+        "type": "complex_key",
+        "title": "unicode key",
+        "": "apple"
+    }
+]
+
+
+class KeyTests(mango.DbPerClass):
+    @classmethod
+    def setUpClass(klass):
+        super(KeyTests, klass).setUpClass()
+        klass.db.save_docs(TEST_DOCS, w=3)
+        klass.db.create_index(["type"])
+
+    def test_dot_key(self):
+        fields = ["title", "dot\\.key", "none.dot"]
+        docs = self.db.find({"type": "complex_key"}, fields = fields)
+        assert len(docs) == 4
+        assert docs[1].has_key("dot.key")
+        assert docs[1]["dot.key"] == "dot's value"
+        assert docs[1].has_key("none")
+        assert docs[1]["none"]["dot"] == "none dot's value"
+
+    def test_peso_key(self):
+        fields = ["title", "$key", "deep.$key"]
+        docs = self.db.find({"type": "complex_key"}, fields = fields)
+        assert len(docs) == 4
+        assert docs[2].has_key("$key")
+        assert docs[2]["$key"] == "peso"
+        assert docs[2].has_key("deep")
+        assert docs[2]["deep"]["$key"] == "deep peso"
+
+    def test_unicode_key(self):
+        docs = self.db.find({"type": "complex_key"}, fields = ["title", ""])
+        assert len(docs) == 4
+        # note:  == \uf8ff
+        assert docs[3].has_key(u'\uf8ff')
+        assert docs[3][u'\uf8ff'] == "apple"

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/08c33202/test/user_docs.py
----------------------------------------------------------------------
diff --git a/test/user_docs.py b/test/user_docs.py
index 465370a..972eafc 100644
--- a/test/user_docs.py
+++ b/test/user_docs.py
@@ -78,8 +78,7 @@ def add_view_indexes(db, kwargs):
         ["manager"],
         ["favorites"],
         ["favorites.3"],
-        ["twitter"],
-        ["type"]
+        ["twitter"]
     ]
     for idx in indexes:
         assert db.create_index(idx) is True
@@ -488,30 +487,5 @@ DOCS = [
             "Python",
             "Lisp"
         ]
-    },
-    {
-        "type": "complex_key",
-        "title": "normal key"
-    },
-    {
-        "type": "complex_key",
-        "title": "key with dot",
-        "dot.key": "dot's value",
-        "none": {
-            "dot": "none dot's value"
-        }
-    },
-    {
-        "type": "complex_key",
-        "title": "key with peso",
-        "$key": "peso",
-        "deep": {
-            "$key": "deep peso"
-        }
-    },
-    {
-        "type": "complex_key",
-        "title": "unicode key",
-        "": "apple"
     }
 ]


Mime
View raw message