This is an automated email from the ASF dual-hosted git repository. willholley pushed a commit to branch mango-run-tests in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 5ef4427a1c815213b35633a813371f9fe1ca45e5 Author: Will Holley <[email protected]> AuthorDate: Mon Oct 16 11:56:39 2023 +0000 mango: do not skip json tests when clouseau installed Previously, Mango tests which only apply to JSON indexes were being skipped if the clouseau (text index) service was enabled for the CouchDB instance being tested against, resulting in tests being skipped in some CI cases. This refactors the tests so that we execute these tests on JSON / all_docs indexes regardless of whether clouseau is present or not. --- src/mango/test/03-operator-test.py | 76 ++++++++++++-------------------------- 1 file changed, 23 insertions(+), 53 deletions(-) diff --git a/src/mango/test/03-operator-test.py b/src/mango/test/03-operator-test.py index ed5eb3847..3046d65ac 100644 --- a/src/mango/test/03-operator-test.py +++ b/src/mango/test/03-operator-test.py @@ -66,19 +66,6 @@ class OperatorTests: docs = self.db.find({"emptybang": {"$allMatch": {"foo": {"$eq": 2}}}}) self.assertEqual(len(docs), 0) - @unittest.skipUnless( - not mango.has_text_service(), - "text indexes do not support the $keyMapMatch operator", - ) - def test_keymap_match(self): - amdocs = [ - {"foo": {"aa": "bar", "bb": "bang"}}, - {"foo": {"cc": "bar", "bb": "bang"}}, - ] - self.db.save_docs(amdocs, w=3) - docs = self.db.find({"foo": {"$keyMapMatch": {"$eq": "aa"}}}) - self.assertEqual(len(docs), 1) - def test_in_operator_array(self): docs = self.db.find({"manager": True, "favorites": {"$in": ["Ruby", "Python"]}}) self.assertUserIds([2, 6, 7, 9, 11, 12], docs) @@ -121,28 +108,6 @@ class OperatorTests: for d in docs: self.assertIn("twitter", d) - # ideally this work be consistent across index types but, alas, it is not - @unittest.skipUnless( - not mango.has_text_service(), - "text indexes do not support range queries across type boundaries", - ) - def test_lt_includes_null_but_not_missing(self): - docs = self.db.find({"twitter": {"$lt": 1}}) - user_ids = [9] - self.assertUserIds(user_ids, docs) - for d in docs: - self.assertEqual(d["twitter"], None) - - @unittest.skipUnless( - not mango.has_text_service(), - "text indexes do not support range queries across type boundaries", - ) - def test_lte_includes_null_but_not_missing(self): - docs = self.db.find({"twitter": {"$lt": 1}}) - user_ids = [9] - self.assertUserIds(user_ids, docs) - for d in docs: - self.assertEqual(d["twitter"], None) def test_lte_null_includes_null_but_not_missing(self): docs = self.db.find({"twitter": {"$lte": None}}) @@ -170,27 +135,32 @@ class OperatorTests: for d in docs: self.assertNotIn("twitter", d) - @unittest.skipUnless( - not mango.has_text_service(), - "text indexes do not support range queries across type boundaries", - ) - def test_lte_respsects_unicode_collation(self): - docs = self.db.find({"ordered": {"$lte": "a"}}) - user_ids = [7, 8, 9, 10, 11, 12] - self.assertUserIds(user_ids, docs) - @unittest.skipUnless( - not mango.has_text_service(), - "text indexes do not support range queries across type boundaries", - ) - def test_gte_respsects_unicode_collation(self): - docs = self.db.find({"ordered": {"$gte": "a"}}) - user_ids = [12, 13, 14] +class OperatorJSONTests(mango.UserDocsTests, OperatorTests): + # ideally this work be consistent across index types but, alas, it is not + def test_lt_includes_null_but_not_missing(self): + docs = self.db.find({"twitter": {"$lt": 1}}) + user_ids = [9] self.assertUserIds(user_ids, docs) + for d in docs: + self.assertEqual(d["twitter"], None) + # text indexes do not support range queries across type boundaries so only + # test this for JSON indexes + def test_lte_respects_unicode_collation(self): + docs = self.db.find({"ordered": {"$lte": "a"}}) + user_ids = [7, 8, 9, 10, 11, 12] + self.assertUserIds(user_ids, docs) -class OperatorJSONTests(mango.UserDocsTests, OperatorTests): - pass + # $keyMapMatch operator is only supported for JSON indexes + def test_keymap_match(self): + amdocs = [ + {"foo": {"aa": "bar", "bb": "bang"}}, + {"foo": {"cc": "bar", "bb": "bang"}}, + ] + self.db.save_docs(amdocs, w=3) + docs = self.db.find({"foo": {"$keyMapMatch": {"$eq": "aa"}}}) + self.assertEqual(len(docs), 1) @unittest.skipUnless(mango.has_text_service(), "requires text service") @@ -198,7 +168,7 @@ class OperatorTextTests(mango.UserDocsTextTests, OperatorTests): pass -class OperatorAllDocsTests(mango.UserDocsTestsNoIndexes, OperatorTests): +class OperatorAllDocsTests(mango.UserDocsTestsNoIndexes, OperatorJSONTests): def test_range_id_eq(self): doc_id = "8e1c90c0-ac18-4832-8081-40d14325bde0" r = self.db.find({"_id": doc_id}, explain=True, return_raw=True)
