Skip to content

Commit 4726951

Browse files
committed
Added new checks command to cci
1 parent fc8342e commit 4726951

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

cumulusci/cli/cci.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from cumulusci.utils.http.requests_utils import init_requests_trust
1919
from cumulusci.utils.logging import tee_stdout_stderr
2020

21+
from .checks import checks
2122
from .error import error
2223
from .flow import flow
2324
from .logger import get_tempfile_logger, init_logger
@@ -242,3 +243,4 @@ def shell(runtime, script=None, python=None):
242243
cli.add_command(flow)
243244
cli.add_command(plan)
244245
cli.add_command(robot)
246+
cli.add_command(checks)

cumulusci/cli/checks.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import click
2+
3+
from .runtime import pass_runtime
4+
5+
6+
@click.group("checks", help="Commands for running preflight checks for a plan")
7+
def checks():
8+
pass
9+
10+
11+
@checks.command(name="info", help="Displays preflight checks for a plan")
12+
@click.argument("plan_name")
13+
@pass_runtime(require_project=True)
14+
def checks_info(runtime, plan_name):
15+
click.echo("This plan has the following preflight checks: ")
16+
17+
18+
@checks.command(name="run", help="Runs checks under a plan")
19+
@click.argument("plan_name")
20+
@click.option(
21+
"--org",
22+
help="Specify the target org. By default, runs against the current default org",
23+
)
24+
@pass_runtime(require_keychain=True, require_project=True)
25+
def checks_run(runtime, plan_name, org):
26+
27+
# Get necessary configs
28+
org, org_config = runtime.get_org(org)
29+
m = "Running checks for the plan " + plan_name
30+
click.echo(m)

cumulusci/cli/tests/test_checks.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
from unittest import mock
2+
3+
from cumulusci.cli.runtime import CliRuntime
4+
5+
from .. import checks
6+
from .utils import run_click_command
7+
8+
9+
@mock.patch("click.echo")
10+
def test_flow_info(echo):
11+
12+
runtime = CliRuntime(
13+
config={
14+
"flows": {
15+
"test": {
16+
"steps": {
17+
1: {
18+
"task": "test_task",
19+
"options": {"option_name": "option_value"},
20+
}
21+
}
22+
}
23+
},
24+
"tasks": {
25+
"test_task": {
26+
"class_path": "cumulusci.cli.tests.test_flow.DummyTask",
27+
"description": "Test Task",
28+
}
29+
},
30+
},
31+
load_keychain=False,
32+
)
33+
34+
run_click_command(checks.checks_info, runtime=runtime, plan_name="test")
35+
36+
echo.assert_called_with("This plan has the following preflight checks: ")
37+
38+
39+
@mock.patch("click.echo")
40+
def test_checks_run(echo):
41+
org_config = mock.Mock(scratch=True, config={})
42+
runtime = CliRuntime(
43+
config={
44+
"flows": {"test": {"steps": {1: {"task": "test_task"}}}},
45+
"tasks": {
46+
"test_task": {
47+
"class_path": "cumulusci.cli.tests.test_flow.DummyTask",
48+
"description": "Test Task",
49+
}
50+
},
51+
},
52+
load_keychain=False,
53+
)
54+
runtime.get_org = mock.Mock(return_value=("test", org_config))
55+
56+
run_click_command(
57+
checks.checks_run,
58+
runtime=runtime,
59+
plan_name="test",
60+
org="test",
61+
)
62+
63+
echo.assert_called_with("Running checks for the plan test")

0 commit comments

Comments
 (0)