Skip to content

Commit

Permalink
Added new checks command to cci
Browse files Browse the repository at this point in the history
  • Loading branch information
jain-naman-sf committed Jan 29, 2025
1 parent fc8342e commit 4726951
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cumulusci/cli/cci.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from cumulusci.utils.http.requests_utils import init_requests_trust
from cumulusci.utils.logging import tee_stdout_stderr

from .checks import checks
from .error import error
from .flow import flow
from .logger import get_tempfile_logger, init_logger
Expand Down Expand Up @@ -242,3 +243,4 @@ def shell(runtime, script=None, python=None):
cli.add_command(flow)
cli.add_command(plan)
cli.add_command(robot)
cli.add_command(checks)
30 changes: 30 additions & 0 deletions cumulusci/cli/checks.py
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)
63 changes: 63 additions & 0 deletions cumulusci/cli/tests/test_checks.py
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")

0 comments on commit 4726951

Please sign in to comment.