-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc8342e
commit 4726951
Showing
3 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import click | ||
|
||
from .runtime import pass_runtime | ||
|
||
|
||
@click.group("checks", help="Commands for running preflight checks for a plan") | ||
def checks(): | ||
pass | ||
|
||
|
||
@checks.command(name="info", help="Displays preflight checks for a plan") | ||
@click.argument("plan_name") | ||
@pass_runtime(require_project=True) | ||
def checks_info(runtime, plan_name): | ||
click.echo("This plan has the following preflight checks: ") | ||
|
||
|
||
@checks.command(name="run", help="Runs checks under a plan") | ||
@click.argument("plan_name") | ||
@click.option( | ||
"--org", | ||
help="Specify the target org. By default, runs against the current default org", | ||
) | ||
@pass_runtime(require_keychain=True, require_project=True) | ||
def checks_run(runtime, plan_name, org): | ||
|
||
# Get necessary configs | ||
org, org_config = runtime.get_org(org) | ||
m = "Running checks for the plan " + plan_name | ||
click.echo(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from unittest import mock | ||
|
||
from cumulusci.cli.runtime import CliRuntime | ||
|
||
from .. import checks | ||
from .utils import run_click_command | ||
|
||
|
||
@mock.patch("click.echo") | ||
def test_flow_info(echo): | ||
|
||
runtime = CliRuntime( | ||
config={ | ||
"flows": { | ||
"test": { | ||
"steps": { | ||
1: { | ||
"task": "test_task", | ||
"options": {"option_name": "option_value"}, | ||
} | ||
} | ||
} | ||
}, | ||
"tasks": { | ||
"test_task": { | ||
"class_path": "cumulusci.cli.tests.test_flow.DummyTask", | ||
"description": "Test Task", | ||
} | ||
}, | ||
}, | ||
load_keychain=False, | ||
) | ||
|
||
run_click_command(checks.checks_info, runtime=runtime, plan_name="test") | ||
|
||
echo.assert_called_with("This plan has the following preflight checks: ") | ||
|
||
|
||
@mock.patch("click.echo") | ||
def test_checks_run(echo): | ||
org_config = mock.Mock(scratch=True, config={}) | ||
runtime = CliRuntime( | ||
config={ | ||
"flows": {"test": {"steps": {1: {"task": "test_task"}}}}, | ||
"tasks": { | ||
"test_task": { | ||
"class_path": "cumulusci.cli.tests.test_flow.DummyTask", | ||
"description": "Test Task", | ||
} | ||
}, | ||
}, | ||
load_keychain=False, | ||
) | ||
runtime.get_org = mock.Mock(return_value=("test", org_config)) | ||
|
||
run_click_command( | ||
checks.checks_run, | ||
runtime=runtime, | ||
plan_name="test", | ||
org="test", | ||
) | ||
|
||
echo.assert_called_with("Running checks for the plan test") |