Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/acrcssc/azext_acrcssc/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,16 @@ def _validate_schedule(schedule):
raise InvalidArgumentValueError(error_msg=ERROR_MESSAGE_INVALID_TIMESPAN_VALUE, recommendation=RECOMMENDATION_SCHEDULE)


def validate_inputs(schedule, config_file_path=None):
def validate_inputs(schedule, config_file_path=None, dryrun=False, run_immediately=False):
_validate_schedule(schedule)
if config_file_path is not None:
validate_continuouspatch_config_v1(config_file_path)
validate_run_type(dryrun, run_immediately)


def validate_run_type(dryrun, run_immediately):
if dryrun and run_immediately:
raise InvalidArgumentValueError(error_msg="The --dryrun and --run-immediately options cannot be used together. Use one or the other.")


def validate_task_type(task_type):
Expand Down
2 changes: 1 addition & 1 deletion src/acrcssc/azext_acrcssc/cssc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _perform_continuous_patch_operation(cmd,
acr_client_registries = cf_acr_registries(cmd.cli_ctx, None)
registry = acr_client_registries.get(resource_group_name, registry_name)

validate_inputs(schedule, config)
validate_inputs(schedule, config, dryrun, run_immediately)

if not is_create:
validate_cssc_optional_inputs(config, schedule)
Expand Down
22 changes: 21 additions & 1 deletion src/acrcssc/azext_acrcssc/tests/latest/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import unittest
from unittest import mock
from ..._validators import (
_validate_schedule, check_continuous_task_exists, validate_continuouspatch_config_v1
_validate_schedule, validate_run_type, check_continuous_task_exists, validate_continuouspatch_config_v1
)

from azure.cli.core.azclierror import AzCLIError, InvalidArgumentValueError
Expand All @@ -35,6 +35,26 @@ def test_validate_schedule_invalid(self):
for timespan in test_cases:
self.assertRaises(InvalidArgumentValueError, _validate_schedule, timespan)

def test_validate_run_type_valid(self):
test_cases = [
(True, False),
(False, True),
(False, False)
]

for dryrun, run_immediately in test_cases:
with self.subTest(dryrun=dryrun, run_immediately=run_immediately):
validate_run_type(dryrun, run_immediately)

def test_validate_run_type_invalid(self):
test_cases = [
(True, True)
]

for dryrun, run_immediately in test_cases:
with self.subTest(dryrun=dryrun, run_immediately=run_immediately):
self.assertRaises(InvalidArgumentValueError, validate_run_type, dryrun, run_immediately)

@patch('azext_acrcssc._validators.cf_acr_tasks')
def test_check_continuoustask_exists(self, mock_cf_acr_tasks):
cmd = self._setup_cmd()
Expand Down