You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2021/11/12 19:56:21 UTC

[couchdb] 07/07: Fix Python formatting, restore python-black target

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

kocolosk pushed a commit to branch consolidate-elixir-targets
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 58de567be0df6296f8b82044609891e97b9877e2
Author: Adam Kocoloski <ko...@apache.org>
AuthorDate: Fri Nov 12 14:49:15 2021 -0500

    Fix Python formatting, restore python-black target
    
    This also allows us to eliminate the `check-all-tests` target, since
    we've re-enabled all the test suites (and excluded specific tests as
    needed).
---
 Makefile                                       | 11 +----------
 build-aux/logfile-uploader.py                  |  6 +++---
 dev/run                                        | 12 ++++++++----
 src/mango/test/01-index-crud-test.py           | 12 +++++-------
 src/mango/test/05-index-selection-test.py      |  2 +-
 src/mango/test/12-use-correct-index-test.py    | 20 +++++++++++++++-----
 src/mango/test/13-users-db-find-test.py        |  1 +
 src/mango/test/15-execution-stats-test.py      |  4 +---
 src/mango/test/19-find-conflicts.py            |  1 +
 src/mango/test/22-build-wait-selected-index.py | 10 +++++-----
 src/mango/test/user_docs.py                    |  7 +++++--
 11 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/Makefile b/Makefile
index df70cb3..fd7ea77 100644
--- a/Makefile
+++ b/Makefile
@@ -142,15 +142,6 @@ fauxton: share/www
 ################################################################################
 
 
-# When we can run all the tests with FDB switch this back to be the default
-# "make check" command
-.PHONY: check-all-tests
-# target: check - Test everything
-check-all-tests: all python-black
-	@$(MAKE) eunit
-	@$(MAKE) mango-test
-	@$(MAKE) elixir
-
 ifdef apps
 subdirs=$(shell echo $(apps) | sed 's/,/ /g')
 else
@@ -158,7 +149,7 @@ subdirs=$(shell ls src)
 endif
 
 .PHONY: check
-check:  all 
+check:  all python-black
 	@$(MAKE) erlfmt-check
 	@$(MAKE) eunit
 	@$(MAKE) elixir-suite
diff --git a/build-aux/logfile-uploader.py b/build-aux/logfile-uploader.py
index 3df9e6c..f33915a 100755
--- a/build-aux/logfile-uploader.py
+++ b/build-aux/logfile-uploader.py
@@ -34,7 +34,7 @@ def _tojson(req):
 
 
 def collect_logfiles():
-    """ Find and tarball all logfiles """
+    """Find and tarball all logfiles"""
     tb = tarfile.open(name=TARFILE, mode="w:gz")
     # Test results
     for log in glob.glob("test-results.log"):
@@ -52,7 +52,7 @@ def collect_logfiles():
 
 
 def build_ci_doc():
-    """ Build a metadata document with relevant detail from CI env """
+    """Build a metadata document with relevant detail from CI env"""
     doc = {}
     if "TRAVIS" in os.environ:
         doc["builder"] = "travis"
@@ -125,7 +125,7 @@ def upload_logs():
 
 
 def main():
-    """ Find latest logfile and upload to Couch logfile db. """
+    """Find latest logfile and upload to Couch logfile db."""
     print("Uploading logfiles...")
     collect_logfiles()
     req = upload_logs()
diff --git a/dev/run b/dev/run
index 3fe1b33..ecc45c9 100755
--- a/dev/run
+++ b/dev/run
@@ -287,8 +287,9 @@ def check_boot_script(ctx):
 @log("Prepare configuration files")
 def setup_configs(ctx):
     for idx, node in enumerate(ctx["nodes"]):
-        cluster_port, backend_port, prometheus_port = get_ports(ctx,
-            idx + ctx["node_number"])
+        cluster_port, backend_port, prometheus_port = get_ports(
+            ctx, idx + ctx["node_number"]
+        )
         env = {
             "prefix": toposixpath(ctx["rootdir"]),
             "package_author_name": "The Apache Software Foundation",
@@ -362,8 +363,11 @@ def apply_config_overrides(ctx, content):
 def get_ports(ctx, idnode):
     assert idnode
     if idnode <= 5 and not ctx["auto_ports"]:
-        return ((10000 * idnode) + 5984, (10000 * idnode) + 5986,
-            (10000 * idnode) + 7986)
+        return (
+            (10000 * idnode) + 5984,
+            (10000 * idnode) + 5986,
+            (10000 * idnode) + 7986,
+        )
     else:
         return tuple(get_available_ports(2))
 
diff --git a/src/mango/test/01-index-crud-test.py b/src/mango/test/01-index-crud-test.py
index 13ae300..ea00e3e 100644
--- a/src/mango/test/01-index-crud-test.py
+++ b/src/mango/test/01-index-crud-test.py
@@ -117,14 +117,12 @@ class IndexCrudTests(mango.DbPerClass):
         fields = ["baz", "foo"]
         ret = self.db.create_index(fields, name="idx_02")
         assert ret is True
-        self.db.save_doc({
-            "_id": "_design/ignore",
-            "views": {
-                "view1": {
-                    "map": "function (doc) { emit(doc._id, 1)}"
-                }
+        self.db.save_doc(
+            {
+                "_id": "_design/ignore",
+                "views": {"view1": {"map": "function (doc) { emit(doc._id, 1)}"}},
             }
-        })
+        )
         indexes = self.db.list_indexes()
         self.assertEqual(len(indexes), 2)
 
diff --git a/src/mango/test/05-index-selection-test.py b/src/mango/test/05-index-selection-test.py
index bae3d58..8c683b2 100644
--- a/src/mango/test/05-index-selection-test.py
+++ b/src/mango/test/05-index-selection-test.py
@@ -207,7 +207,7 @@ class IndexSelectionTests:
             self.db.save_doc(design_doc)
             assert False, "Should not get here."
         except requests.exceptions.HTTPError as e:
-            self.assertEqual(e.response.json()['error'], 'invalid_design_doc')
+            self.assertEqual(e.response.json()["error"], "invalid_design_doc")
 
     def test_explain_sort_reverse(self):
         selector = {"manager": {"$gt": None}}
diff --git a/src/mango/test/12-use-correct-index-test.py b/src/mango/test/12-use-correct-index-test.py
index a7f07b5..47ed9df 100644
--- a/src/mango/test/12-use-correct-index-test.py
+++ b/src/mango/test/12-use-correct-index-test.py
@@ -54,14 +54,18 @@ class ChooseCorrectIndexForDocs(mango.DbPerClass):
         self.db.save_docs(copy.deepcopy(DOCS))
 
     def test_choose_index_with_one_field_in_index(self):
-        self.db.create_index(["name", "age", "user_id"], ddoc="aaa", wait_for_built_index=False)
+        self.db.create_index(
+            ["name", "age", "user_id"], ddoc="aaa", wait_for_built_index=False
+        )
         self.db.create_index(["name"], ddoc="zzz", wait_for_built_index=False)
         self.db.wait_for_built_indexes()
         explain = self.db.find({"name": "Eddie"}, explain=True)
         self.assertEqual(explain["index"]["ddoc"], "_design/zzz")
 
     def test_choose_index_with_two(self):
-        self.db.create_index(["name", "age", "user_id"], ddoc="aaa", wait_for_built_index=False)
+        self.db.create_index(
+            ["name", "age", "user_id"], ddoc="aaa", wait_for_built_index=False
+        )
         self.db.create_index(["name", "age"], ddoc="bbb", wait_for_built_index=False)
         self.db.create_index(["name"], ddoc="zzz", wait_for_built_index=False)
         self.db.wait_for_built_indexes()
@@ -77,7 +81,9 @@ class ChooseCorrectIndexForDocs(mango.DbPerClass):
         self.assertEqual(explain["index"]["ddoc"], "_design/aaa")
 
     def test_choose_index_most_accurate(self):
-        self.db.create_index(["name", "age", "user_id"], ddoc="aaa", wait_for_built_index=False)
+        self.db.create_index(
+            ["name", "age", "user_id"], ddoc="aaa", wait_for_built_index=False
+        )
         self.db.create_index(["name", "age"], ddoc="bbb", wait_for_built_index=False)
         self.db.create_index(["name"], ddoc="zzz", wait_for_built_index=False)
         self.db.wait_for_built_indexes()
@@ -85,8 +91,12 @@ class ChooseCorrectIndexForDocs(mango.DbPerClass):
         self.assertEqual(explain["index"]["ddoc"], "_design/bbb")
 
     def test_choose_index_most_accurate_in_memory_selector(self):
-        self.db.create_index(["name", "location", "user_id"], ddoc="aaa", wait_for_built_index=False)
-        self.db.create_index(["name", "age", "user_id"], ddoc="bbb", wait_for_built_index=False)
+        self.db.create_index(
+            ["name", "location", "user_id"], ddoc="aaa", wait_for_built_index=False
+        )
+        self.db.create_index(
+            ["name", "age", "user_id"], ddoc="bbb", wait_for_built_index=False
+        )
         self.db.create_index(["name"], ddoc="zzz", wait_for_built_index=False)
         self.db.wait_for_built_indexes()
         explain = self.db.find({"name": "Eddie", "number": {"$lte": 12}}, explain=True)
diff --git a/src/mango/test/13-users-db-find-test.py b/src/mango/test/13-users-db-find-test.py
index 9f9b53a..11bca8a 100644
--- a/src/mango/test/13-users-db-find-test.py
+++ b/src/mango/test/13-users-db-find-test.py
@@ -16,6 +16,7 @@ import mango, requests, unittest
 
 # Re-enable once the _users db is implemented
 
+
 class UsersDbFindTests(mango.UsersDbTests):
     @classmethod
     def setUpClass(klass):
diff --git a/src/mango/test/15-execution-stats-test.py b/src/mango/test/15-execution-stats-test.py
index 6ccc04b..777fcff 100644
--- a/src/mango/test/15-execution-stats-test.py
+++ b/src/mango/test/15-execution-stats-test.py
@@ -33,9 +33,7 @@ class ExecutionStatsTests(mango.UserDocsTests):
         assert "execution_stats" not in resp
 
     def test_quorum_json_index(self):
-        resp = self.db.find(
-            {"age": {"$lt": 35}}, return_raw=True, executionStats=True
-        )
+        resp = self.db.find({"age": {"$lt": 35}}, return_raw=True, executionStats=True)
         self.assertEqual(len(resp["docs"]), 3)
         self.assertEqual(resp["execution_stats"]["total_keys_examined"], 0)
         self.assertEqual(resp["execution_stats"]["total_docs_examined"], 3)
diff --git a/src/mango/test/19-find-conflicts.py b/src/mango/test/19-find-conflicts.py
index 3bf3c06..2f68293 100644
--- a/src/mango/test/19-find-conflicts.py
+++ b/src/mango/test/19-find-conflicts.py
@@ -19,6 +19,7 @@ DOC = [{"_id": "doc", "a": 2}, {"_id": "doc1", "b": 2}]
 CONFLICT = [{"_id": "doc", "_rev": "1-23202479633c2b380f79507a776743d5", "a": 1}]
 CONFLICT2 = [{"_id": "doc1", "_rev": "1-23202479633c2b380f79507a776743d5", "b": 1}]
 
+
 class ChooseCorrectIndexForDocs(mango.DbPerClass):
     def setUp(self):
         self.db.recreate()
diff --git a/src/mango/test/22-build-wait-selected-index.py b/src/mango/test/22-build-wait-selected-index.py
index fd856f4..76b6092 100644
--- a/src/mango/test/22-build-wait-selected-index.py
+++ b/src/mango/test/22-build-wait-selected-index.py
@@ -28,23 +28,23 @@ class BuildAndWaitOnSelectedIndex(mango.DbPerClass):
     def test_wait_for_query(self):
         self.db.create_index(["val"], ddoc="my-ddoc", wait_for_built_index=False)
 
-        explain = self.db.find({'val': {"$gt": 990}}, use_index="my-ddoc", explain=True)
+        explain = self.db.find({"val": {"$gt": 990}}, use_index="my-ddoc", explain=True)
         self.assertEqual(explain["index"]["ddoc"], "_design/my-ddoc")
 
-        docs = self.db.find({'val': {"$gte": 990}}, limit=10)
+        docs = self.db.find({"val": {"$gte": 990}}, limit=10)
 
         self.assertEqual(len(docs), 10)
 
     def test_dont_wait(self):
         self.db.create_index(["val"], ddoc="my-ddoc", wait_for_built_index=False)
 
-        explain = self.db.find({'val': {"$gt": 990}}, explain=True)
+        explain = self.db.find({"val": {"$gt": 990}}, explain=True)
         self.assertEqual(explain["index"]["name"], "_all_docs")
 
-        docs = self.db.find({'val': {"$gte": 990}})
+        docs = self.db.find({"val": {"$gte": 990}})
         self.assertEqual(len(docs), 10)
 
     def test_update_false(self):
         self.db.create_index(["val"], ddoc="my-ddoc", wait_for_built_index=False)
-        docs = self.db.find({'val': {"$gte": 990}}, update=False, use_index="my-ddoc")
+        docs = self.db.find({"val": {"$gte": 990}}, update=False, use_index="my-ddoc")
         self.assertEqual(docs, [])
diff --git a/src/mango/test/user_docs.py b/src/mango/test/user_docs.py
index c301983..12bc6f2 100644
--- a/src/mango/test/user_docs.py
+++ b/src/mango/test/user_docs.py
@@ -71,6 +71,7 @@ def setup(db, index_type="view", **kwargs):
         add_text_indexes(db, kwargs)
     db.save_docs(copy.deepcopy(DOCS))
 
+
 def add_view_indexes(db, kwargs):
     indexes = [
         (["user_id"], "user_id"),
@@ -93,8 +94,10 @@ def add_view_indexes(db, kwargs):
         (["ordered"], "ordered"),
     ]
     for (idx, name) in indexes:
-        assert db.create_index(idx, name=name, ddoc=name,
-                               wait_for_built_index=False) is True
+        assert (
+            db.create_index(idx, name=name, ddoc=name, wait_for_built_index=False)
+            is True
+        )
     db.wait_for_built_indexes()