This is an automated email from the ASF dual-hosted git repository.

willholley pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 563b904  Fix Mango text index tests (#971)
563b904 is described below

commit 563b9049ab0cc989ece4a26f931933db926027f0
Author: Will Holley <[email protected]>
AuthorDate: Tue Nov 14 13:20:15 2017 +0000

    Fix Mango text index tests (#971)
    
    The text index tests are not routinely run by the Couch CI
    (due to an external dependency that isn't shipped with Couch).
    This fixes a number of tests that were broken as a result of
    recent feature changes.
---
 src/mango/test/05-index-selection-test.py          |  8 ++----
 src/mango/test/06-basic-text-test.py               | 33 +++++++++++-----------
 .../test/10-disable-array-length-field-test.py     |  2 +-
 src/mango/test/16-index-selectors-test.py          |  2 +-
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/mango/test/05-index-selection-test.py 
b/src/mango/test/05-index-selection-test.py
index 05571a7..4994617 100644
--- a/src/mango/test/05-index-selection-test.py
+++ b/src/mango/test/05-index-selection-test.py
@@ -181,15 +181,13 @@ class JSONIndexSelectionTests(mango.UserDocsTests, 
IndexSelectionTests):
 
 
 @unittest.skipUnless(mango.has_text_service(), "requires text service")
-class TextIndexSelectionTests(mango.UserDocsTests, IndexSelectionTests):
+class TextIndexSelectionTests(mango.UserDocsTests):
 
     @classmethod
     def setUpClass(klass):
         super(TextIndexSelectionTests, klass).setUpClass()
-
-    def setUp(self):
-        self.db.recreate()
-        user_docs.add_text_indexes(self.db, {})
+        if mango.has_text_service():
+            user_docs.add_text_indexes(klass.db, {})
 
     def test_with_text(self):
         resp = self.db.find({
diff --git a/src/mango/test/06-basic-text-test.py 
b/src/mango/test/06-basic-text-test.py
index c02950c..3783006 100644
--- a/src/mango/test/06-basic-text-test.py
+++ b/src/mango/test/06-basic-text-test.py
@@ -450,14 +450,14 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             }
         }
         docs = self.db.find(q)
-        assert len(docs) == 1
-        assert docs[0]["bestfriends"] == ["Wolverine", "Cyclops"]
+        self.assertEqual(len(docs), 1)
+        self.assertEqual(docs[0]["bestfriends"], ["Wolverine", "Cyclops"])
 
         q = {"results": {"$elemMatch": {"$gte": 80, "$lt": 85}}}
 
         docs = self.db.find(q)
-        assert len(docs) == 1
-        assert docs[0]["results"] == [82, 85, 88]
+        self.assertEqual(len(docs), 1)
+        self.assertEqual(docs[0]["results"], [82, 85, 88])
 
     def test_elem_match(self):
         q = {"friends": {
@@ -466,9 +466,9 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             }
         }
         docs = self.db.find(q)
-        assert len(docs) == 2
+        self.assertEqual(len(docs), 2)
         for d in docs:
-            assert d["user_id"] in (0, 1)
+            self.assertIn(d["user_id"], (0, 1))
 
         q = {
             "friends": {
@@ -479,8 +479,8 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             }
         }
         docs = self.db.find(q)
-        assert len(docs) == 1
-        assert docs[0]["user_id"] == 4
+        self.assertEqual(len(docs), 1)
+        self.assertEqual(docs[0]["user_id"], 4)
 
 
         # Check that we can do logic in elemMatch
@@ -490,8 +490,9 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             }}
         }
         docs = self.db.find(q)
-        assert len(docs) == 1
-        assert docs[0]["user_id"] == 1
+        self.assertEqual(len(docs), 2)
+        for d in docs:
+            self.assertIn(d["user_id"], (1, 15))
 
         q = {
             "friends": {
@@ -505,9 +506,9 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             }
         }
         docs = self.db.find(q)
-        assert len(docs) == 2
+        self.assertEqual(len(docs), 3)
         for d in docs:
-            assert d["user_id"] in (1, 4)
+            self.assertIn(d["user_id"], (1, 4, 15))
 
         # Same as last, but using $in
         q = {
@@ -519,9 +520,9 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             }
         }
         docs = self.db.find(q)
-        assert len(docs) == 2
+        self.assertEqual(len(docs), 3)
         for d in docs:
-            assert d["user_id"] in (1, 4)
+            self.assertIn(d["user_id"], (1, 4, 15))
 
         q = {
             "$and": [{
@@ -564,9 +565,9 @@ class ElemMatchTests(mango.FriendDocsTextTests):
             ]
         }
         docs = self.db.find(q)
-        assert len(docs) == 3
+        self.assertEqual(len(docs), 3)
         for d in docs:
-            assert d["user_id"] in (10, 11,12)
+            self.assertIn(d["user_id"], (10, 11,12))
 
 @unittest.skipUnless(mango.has_text_service(), "requires text service")
 class AllMatchTests(mango.FriendDocsTextTests):
diff --git a/src/mango/test/10-disable-array-length-field-test.py 
b/src/mango/test/10-disable-array-length-field-test.py
index ce7713b..6b6d419 100644
--- a/src/mango/test/10-disable-array-length-field-test.py
+++ b/src/mango/test/10-disable-array-length-field-test.py
@@ -16,7 +16,7 @@ import unittest
 @unittest.skipUnless(mango.has_text_service(), "requires text service")
 class DisableIndexArrayLengthsTest(mango.UserDocsTextTests):
 
-    def setUp(klass):
+    def setUp(self):
         self.db.recreate()
         self.db.create_text_index(ddoc="disable_index_array_lengths",
                                        analyzer="keyword",
diff --git a/src/mango/test/16-index-selectors-test.py 
b/src/mango/test/16-index-selectors-test.py
index 6d771cc..389f5f4 100644
--- a/src/mango/test/16-index-selectors-test.py
+++ b/src/mango/test/16-index-selectors-test.py
@@ -273,6 +273,6 @@ class IndexSelectorJson(mango.DbPerClass):
 
     @unittest.skipUnless(mango.has_text_service(), "requires text service")
     def test_text_partial_filter_only_in_return_if_not_default(self):
-        self.db.create_text_index(fields=[{"name":"location"}])
+        self.db.create_text_index(fields=[{"name":"location", 
"type":"string"}])
         index = self.db.list_indexes()[1]
         self.assertEqual('partial_filter_selector' in index['def'], False)

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to