You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/10/16 15:52:40 UTC

[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #12381: [feat] add side cli and tests

zhongjiajie commented on code in PR #12381:
URL: https://github.com/apache/dolphinscheduler/pull/12381#discussion_r996459131


##########
dolphinscheduler-python/pydolphinscheduler/tests/cli/test_project.py:
##########
@@ -0,0 +1,96 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Test command line interface subcommand `project`."""
+
+import pytest
+
+from pydolphinscheduler.cli.commands import cli
+from tests.integration.test_project import get_project
+from tests.testing.cli import CliTestWrapper
+
+
+@pytest.mark.parametrize(
+    "option, output",
+    [
+        (["project", "--set", "test-project", "test-desc", "admin"], None),
+    ],
+)
+def test_project_setter(option, output):
+    """Test subcommand `project` option `--setter`."""
+    cli_test = CliTestWrapper(cli, option)
+    cli_test.assert_success()
+    assert "Set project done." in cli_test.result.output
+
+
+@pytest.mark.parametrize(
+    "option, output",
+    [
+        (["project", "--get", "admin", "test-name-1"], None),
+    ],
+)
+def test_project_getter(option, output):
+    """Test subcommand `project` option `--getter`."""
+    get_project()
+    cli_test = CliTestWrapper(cli, option)
+    cli_test.assert_success()
+    assert (
+        "Project(name=test-name-1, description=test-description, code="
+        in cli_test.result.output
+    )

Review Comment:
   You should mock the function `get_project`, because it come from `from tests.integration.test_project import get_project`. and only code in directory `tests/integration` will start dolphinscheduler standalone server and then run the test. for more detail you can see in https://github.com/apache/dolphinscheduler/blob/dev/dolphinscheduler-python/pydolphinscheduler/DEVELOP.md#integrate-test
   
   and it mean only directory `tests/integration` can communicate to DolphionScheduler Python service, and call get project endpoint
   
   and because you already test the `get_project` in file `tests/integration/test_project`. So I think directly mock it here make sense. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org