Skip to content

Commit

Permalink
tests: refactor test_cli_help test
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Gierszewski <[email protected]>
  • Loading branch information
Kamil Gierszewski committed Dec 11, 2024
1 parent bbcbe92 commit 75b89c8
Showing 1 changed file with 39 additions and 79 deletions.
118 changes: 39 additions & 79 deletions test/functional/tests/cli/test_cli_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,93 +6,53 @@

import pytest

from api.cas import casadm
from api.cas.cli_help_messages import *
from api.cas.cli_messages import check_stderr_msg, check_stdout_msg
from core.test_run import TestRun


@pytest.mark.parametrize("shortcut", [True, False])
@pytest.mark.parametrizex("shortcut", [True, False])
def test_cli_help(shortcut):
"""
title: Test for 'help' command.
description: Test if help for commands displays.
description: |
Test if help for commands displays.
pass_criteria:
- Proper help displays for every command.
"""
TestRun.LOGGER.info("Run 'help' for every 'casadm' command.")
output = casadm.help(shortcut)
check_stdout_msg(output, casadm_help)

output = TestRun.executor.run("casadm" + (" -S" if shortcut else " --start-cache")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, start_cache_help)

output = TestRun.executor.run("casadm" + (" -T" if shortcut else " --stop-cache")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, stop_cache_help)

output = TestRun.executor.run("casadm" + (" -X" if shortcut else " --set-param")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, set_params_help)

output = TestRun.executor.run("casadm" + (" -G" if shortcut else " --get-param")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, get_params_help)

output = TestRun.executor.run("casadm" + (" -Q" if shortcut else " --set-cache-mode")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, set_cache_mode_help)

output = TestRun.executor.run("casadm" + (" -A" if shortcut else " --add-core")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, add_core_help)

output = TestRun.executor.run("casadm" + (" -R" if shortcut else " --remove-core")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, remove_core_help)

output = TestRun.executor.run("casadm" + " --remove-detached"
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, remove_detached_help)

output = TestRun.executor.run("casadm" + (" -L" if shortcut else " --list-caches")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, list_caches_help)

output = TestRun.executor.run("casadm" + (" -P" if shortcut else " --stats")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, stats_help)

output = TestRun.executor.run("casadm" + (" -Z" if shortcut else " --reset-counters")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, reset_counters_help)

output = TestRun.executor.run("casadm" + (" -F" if shortcut else " --flush-cache")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, flush_cache_help)

output = TestRun.executor.run("casadm" + (" -C" if shortcut else " --io-class")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, ioclass_help)

output = TestRun.executor.run("casadm" + (" -V" if shortcut else " --version")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, version_help)

output = TestRun.executor.run("casadm" + (" -H" if shortcut else " --help")
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, help_help)

output = TestRun.executor.run("casadm" + " --standby"
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, standby_help)

output = TestRun.executor.run("casadm" + " --zero-metadata"
+ (" -H" if shortcut else " --help"))
check_stdout_msg(output, zero_metadata_help)

output = TestRun.executor.run("casadm" + (" -Y" if shortcut else " --yell")
+ (" -H" if shortcut else " --help"))
check_stderr_msg(output, unrecognized_stderr)
check_stdout_msg(output, unrecognized_stdout)
check_list_cmd = [
(" -S", " --start-cache", start_cache_help),
# (None, " --attach-cache", attach_cache_help),
# (None, " --detach-cache", detach_cache_help),
(" -T", " --stop-cache", stop_cache_help),
(" -X", " --set-param", set_params_help),
(" -G", " --get-param", get_params_help),
(" -Q", " --set-cache-mode", set_cache_mode_help),
(" -A", " --add-core", add_core_help),
(" -R", " --remove-core", remove_core_help),
(None, "--remove-inactive", remove_inactive_help),
(None, "--remove-detached", remove_detached_help),
(" -L", " --list-caches", list_caches_help),
(" -P", " --stats", stats_help),
(" -Z", " --reset-counters", reset_counters_help),
(" -F", " --flush-cache", flush_cache_help),
(" -C", " --io-class", ioclass_help),
(" -V", " --version", version_help),
# (None, " --standby", standby_help),
(" -H", " --help", help_help),
(" --zero-metadata", zero_metadata_help),
]
help = "-H" if shortcut else "--help"

with TestRun.step("Run 'help' for every 'casadm' command and check output"):
for cmds in check_list_cmd:
cmd = cmds[0] if shortcut else cmds[1]
if cmd:
output = TestRun.executor.run("casadm" + cmd + help)
check_stdout_msg(output, cmds[2])

with TestRun.step("Run 'help' for command that doesn`t exist and check output"):
cmd = "-Y" if shortcut else "--yell"
output = TestRun.executor.run("casadm" + cmd + help)
check_stderr_msg(output, unrecognized_stderr)
check_stdout_msg(output, unrecognized_stdout)

0 comments on commit 75b89c8

Please sign in to comment.