Skip to content

Commit

Permalink
update notsupported lists for lock/unlock and show subcommands
Browse files Browse the repository at this point in the history
add tests to 01-test_argument_parsing.sh
  • Loading branch information
LegenJCdary committed Sep 15, 2022
1 parent d433ddd commit 791da8a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions source/modules/validators/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ def validate_options(self, options: dict):
notsupported = ["switches", "commit"]
elif options["subcommand"] in ("lock", "unlock"):
required = ["infra", "stage"]
notsupported = ["switches", "task", "commit", "limit", "raw_output"]
notsupported = ["switches", "task", "commit", "keep_locked", "limit", "raw_output",
"self_setup"]
elif options["subcommand"] == "show":
notsupported = ["commit", "keep_locked", "limit", "raw_output"]
notsupported = ["task", "infra", "stage", "commit", "dry", "keep_locked", "syslog",
"limit", "raw_output", "self_setup"]

failed = False
for req in required:
Expand Down
13 changes: 13 additions & 0 deletions tests/01-argument_parsing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ check_message_in_output "ansible-deployer lock --task task_exec_bin_true --infra
check_message_in_output "ansible-deployer lock --task task_exec_bin_true --infrastructure testInfra --stage prod" "\[ERROR\]: task is not supported by lock"
check_message_in_output "ansible-deployer lock --task task_exec_bin_true --stage prod" "\[ERROR\]: infra is required for lock"
check_message_in_output "ansible-deployer lock --task task_exec_bin_true --stage prod --commit X" "\[ERROR\]: commit is not supported by lock"
check_message_in_output "ansible-deployer lock --infra testInfra --stage prod --keep-locked" "\[ERROR\]: keep_locked is not supported by lock"
check_message_in_output "ansible-deployer lock --task task_exec_bin_true --limit test_hosts_1" "\[ERROR\]: limit is not supported by lock"
check_message_in_output "ansible-deployer lock --infra testInfra --stage prod --raw-runner-output" "\[ERROR\]: raw_output is not supported by lock"
check_message_in_output "ansible-deployer lock --infra testInfra --stage prod --self-setup ." "\[ERROR\]: self_setup is not supported by lock"

check_message_in_output "ansible-deployer unlock --task task_exec_bin_true --infrastructure testInfra" "\[ERROR\]: task is not supported by unlock"
check_message_in_output "ansible-deployer unlock --task task_exec_bin_true --infrastructure testInfra --stage prod" "\[ERROR\]: task is not supported by unlock"
check_message_in_output "ansible-deployer unlock --task task_exec_bin_true --stage test" "\[ERROR\]: infra is required for unlock"
check_message_in_output "ansible-deployer unlock --task task_exec_bin_true --stage prod --commit X" "\[ERROR\]: commit is not supported by unlock"
check_message_in_output "ansible-deployer unlock --infra testInfra --stage prod --keep-locked" "\[ERROR\]: keep_locked is not supported by unlock"
check_message_in_output "ansible-deployer unlock --task task_exec_bin_true --limit test_hosts_1" "\[ERROR\]: limit is not supported by unlock"
check_message_in_output "ansible-deployer unlock --infra testInfra --stage prod --raw-runner-output" "\[ERROR\]: raw_output is not supported by unlock"
check_message_in_output "ansible-deployer unlock --infra testInfra --stage prod --self-setup ." "\[ERROR\]: self_setup is not supported by unlock"

check_message_in_output "ansible-deployer run test" "\[CRITICAL\]: Too many positional arguments! Only subcommand \"show\" can accept following arguments: all, task, infra."
check_message_in_output "ansible-deployer verify test" "\[CRITICAL\]: Too many positional arguments! Only subcommand \"show\" can accept following arguments: all, task, infra."
Expand All @@ -41,7 +47,14 @@ check_message_in_output "ansible-deployer unlock test" "\[CRITICAL\]: Too many p
check_message_in_output "ansible-deployer show test" "\[CRITICAL\]: Invalid argument test! Subcommand \"show\" can accept only following arguments: all, task, infra."
check_message_in_output "ansible-deployer show --commit task_exec_bin_true" "\[ERROR\]: commit is not supported by show"
check_message_in_output "ansible-deployer show --limit test_hosts_1" "\[ERROR\]: limit is not supported by show"
check_message_in_output "ansible-deployer show --task task_exec_bin_true" "\[ERROR\]: task is not supported by show"
check_message_in_output "ansible-deployer show --infra testInfra" "\[ERROR\]: infra is not supported by show"
check_message_in_output "ansible-deployer show --stage prod" "\[ERROR\]: stage is not supported by show"
check_message_in_output "ansible-deployer show --dry" "\[ERROR\]: dry is not supported by show"
check_message_in_output "ansible-deployer show --keep-locked" "\[ERROR\]: keep_locked is not supported by show"
check_message_in_output "ansible-deployer show --syslog" "\[ERROR\]: syslog is not supported by show"
check_message_in_output "ansible-deployer show --raw-runner-output" "\[ERROR\]: raw_output is not supported by show"
check_message_in_output "ansible-deployer show --self-setup ." "\[ERROR\]: self_setup is not supported by show"

echo -e " ___ _ _ _\n / _ \/ | __ _ _ __ __ _ _ _ _ __ ___ ___ _ __ | |_ _ __ __ _ _ __ ___(_)_ __ __ _\n | | | | | _____ / _\` | '__/ _\` | | | | '_ \` _ \ / _ \ '_ \| __| | '_ \ / _\` | '__/ __| | '_ \ / _\` |\n | |_| | | |_____| | (_| | | | (_| | |_| | | | | | | __/ | | | |_ | |_) | (_| | | \__ \ | | | | (_| |\n \___/|_| \__,_|_| \__, |\__,_|_| |_| |_|\___|_| |_|\__| | .__/ \__,_|_| |___/_|_| |_|\__, |\n |___/ |_| |___/\n _ _ _ _ _\n ___ ___ _ __ _ __ ___ ___| |_ ___ ___ _ __ ___ | |__ (_)_ __ __ _| |_(_) ___ _ __ ___\n / __/ _ \| '__| '__/ _ \/ __| __| / __/ _ \| '_ \` _ \| '_ \| | '_ \ / _\` | __| |/ _ \| '_ \/ __|\n | (_| (_) | | | | | __/ (__| |_ | (_| (_) | | | | | | |_) | | | | | (_| | |_| | (_) | | | \__ \ \n \___\___/|_| |_| \___|\___|\__| \___\___/|_| |_| |_|_.__/|_|_| |_|\__,_|\__|_|\___/|_| |_|___/\n"
# Check if correct combinations are accepted
Expand Down
13 changes: 13 additions & 0 deletions tests/01-argument_parsing_short.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ check_message_in_output "ansible-deployer lock -t task_exec_bin_true -i testInfr
check_message_in_output "ansible-deployer lock -t task_exec_bin_true -i testInfra -s prod" "\[ERROR\]: task is not supported by lock"
check_message_in_output "ansible-deployer lock -t task_exec_bin_true -s prod" "\[ERROR\]: infra is required for lock"
check_message_in_output "ansible-deployer lock -t task_exec_bin_true -s prod -c X" "\[ERROR\]: commit is not supported by lock"
check_message_in_output "ansible-deployer lock -i testInfra -s prod --keep-locked" "\[ERROR\]: keep_locked is not supported by lock"
check_message_in_output "ansible-deployer lock -t task_exec_bin_true -l test_hosts_1" "\[ERROR\]: limit is not supported by lock"
check_message_in_output "ansible-deployer lock -i testInfra -s prod --raw-runner-output" "\[ERROR\]: raw_output is not supported by lock"
check_message_in_output "ansible-deployer lock -i testInfra -s prod --self-setup ." "\[ERROR\]: self_setup is not supported by lock"

check_message_in_output "ansible-deployer unlock -t task_exec_bin_true -i testInfra" "\[ERROR\]: task is not supported by unlock"
check_message_in_output "ansible-deployer unlock -t task_exec_bin_true -i testInfra -s prod" "\[ERROR\]: task is not supported by unlock"
check_message_in_output "ansible-deployer unlock -t task_exec_bin_true -s test" "\[ERROR\]: infra is required for unlock"
check_message_in_output "ansible-deployer unlock -t task_exec_bin_true -s prod -c X" "\[ERROR\]: commit is not supported by unlock"
check_message_in_output "ansible-deployer unlock -i testInfra -s prod --keep-locked" "\[ERROR\]: keep_locked is not supported by unlock"
check_message_in_output "ansible-deployer unlock -t task_exec_bin_true -l test_hosts_1" "\[ERROR\]: limit is not supported by unlock"
check_message_in_output "ansible-deployer unlock -i testInfra -s prod --raw-runner-output" "\[ERROR\]: raw_output is not supported by unlock"
check_message_in_output "ansible-deployer unlock -i testInfra -s prod --self-setup ." "\[ERROR\]: self_setup is not supported by unlock"

check_message_in_output "ansible-deployer run test" "\[CRITICAL\]: Too many positional arguments! Only subcommand \"show\" can accept following arguments: all, task, infra."
check_message_in_output "ansible-deployer verify test" "\[CRITICAL\]: Too many positional arguments! Only subcommand \"show\" can accept following arguments: all, task, infra."
Expand All @@ -41,7 +47,14 @@ check_message_in_output "ansible-deployer unlock test" "\[CRITICAL\]: Too many p
check_message_in_output "ansible-deployer show test" "\[CRITICAL\]: Invalid argument test! Subcommand \"show\" can accept only following arguments: all, task, infra."
check_message_in_output "ansible-deployer show -c task_exec_bin_true" "\[ERROR\]: commit is not supported by show"
check_message_in_output "ansible-deployer show -l test_hosts_1" "\[ERROR\]: limit is not supported by show"
check_message_in_output "ansible-deployer show -t task_exec_bin_true" "\[ERROR\]: task is not supported by show"
check_message_in_output "ansible-deployer show -i testInfra" "\[ERROR\]: infra is not supported by show"
check_message_in_output "ansible-deployer show -s prod" "\[ERROR\]: stage is not supported by show"
check_message_in_output "ansible-deployer show --dry" "\[ERROR\]: dry is not supported by show"
check_message_in_output "ansible-deployer show --keep-locked" "\[ERROR\]: keep_locked is not supported by show"
check_message_in_output "ansible-deployer show --syslog" "\[ERROR\]: syslog is not supported by show"
check_message_in_output "ansible-deployer show --raw-runner-output" "\[ERROR\]: raw_output is not supported by show"
check_message_in_output "ansible-deployer show --self-setup ." "\[ERROR\]: self_setup is not supported by show"

echo -e " ___ _ _ _ _ _\n / _ \/ | __ _ _ __ __ _ _ _ _ __ ___ ___ _ __ | |_ _ __ __ _ _ __ ___(_)_ __ __ _ ___| |__ ___ _ __| |_\n | | | | | _____ / _\` | '__/ _\` | | | | '_ \` _ \ / _ \ '_ \| __| | '_ \ / _\` | '__/ __| | '_ \ / _\` | / __| '_ \ / _ \| '__| __|\n | |_| | | |_____| | (_| | | | (_| | |_| | | | | | | __/ | | | |_ | |_) | (_| | | \__ \ | | | | (_| | \__ \ | | | (_) | | | |_\n \___/|_| \__,_|_| \__, |\__,_|_| |_| |_|\___|_| |_|\__| | .__/ \__,_|_| |___/_|_| |_|\__, | |___/_| |_|\___/|_| \__|\n |___/ |_| |___/\n _ _ _ _ _\n ___ ___ _ __ _ __ ___ ___| |_ ___ ___ _ __ ___ | |__ (_)_ __ __ _| |_(_) ___ _ __ ___\n / __/ _ \| '__| '__/ _ \/ __| __| / __/ _ \| '_ \` _ \| '_ \| | '_ \ / _\` | __| |/ _ \| '_ \/ __|\n | (_| (_) | | | | | __/ (__| |_ | (_| (_) | | | | | | |_) | | | | | (_| | |_| | (_) | | | \__ \ \n \___\___/|_| |_| \___|\___|\__| \___\___/|_| |_| |_|_.__/|_|_| |_|\__,_|\__|_|\___/|_| |_|___/\n"
# Check if correct combinations are accepted
Expand Down

0 comments on commit 791da8a

Please # to comment.