You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2017/11/14 13:20:19 UTC

[GitHub] willholley closed pull request #971: Fix Mango text index tests

willholley closed pull request #971: Fix Mango text index tests
URL: https://github.com/apache/couchdb/pull/971
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/mango/test/05-index-selection-test.py b/src/mango/test/05-index-selection-test.py
index 05571a7e8c..49946171e4 100644
--- a/src/mango/test/05-index-selection-test.py
+++ b/src/mango/test/05-index-selection-test.py
@@ -181,15 +181,13 @@ def test_uses_all_docs_when_selector_doesnt_require_fields_to_exist(self):
 
 
 @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 c02950c46e..3783006ab9 100644
--- a/src/mango/test/06-basic-text-test.py
+++ b/src/mango/test/06-basic-text-test.py
@@ -450,14 +450,14 @@ def test_elem_match_non_object(self):
             }
         }
         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 @@ def test_elem_match(self):
             }
         }
         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 @@ def test_elem_match(self):
             }
         }
         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 @@ def test_elem_match(self):
             }}
         }
         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 @@ def test_elem_match(self):
             }
         }
         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 @@ def test_elem_match(self):
             }
         }
         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 @@ def test_elem_match(self):
             ]
         }
         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 ce7713b63b..6b6d419265 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 @@
 @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 6d771cc4b4..389f5f41e3 100644
--- a/src/mango/test/16-index-selectors-test.py
+++ b/src/mango/test/16-index-selectors-test.py
@@ -273,6 +273,6 @@ def test_text_old_selector_still_supported(self):
 
     @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)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services