Skip to content

Commit 986696b

Browse files
author
Kamil Gierszewski
committed
tests: refactor test_cli_help test
Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
1 parent 4208fb4 commit 986696b

File tree

1 file changed

+40
-79
lines changed

1 file changed

+40
-79
lines changed

test/functional/tests/cli/test_cli_help.py

Lines changed: 40 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,54 @@
66

77
import pytest
88

9-
from api.cas import casadm
109
from api.cas.cli_help_messages import *
1110
from api.cas.cli_messages import check_stderr_msg, check_stdout_msg
1211
from core.test_run import TestRun
1312

1413

15-
@pytest.mark.parametrize("shortcut", [True, False])
14+
@pytest.mark.parametrizex("shortcut", [True, False])
1615
def test_cli_help(shortcut):
1716
"""
1817
title: Test for 'help' command.
19-
description: Test if help for commands displays.
18+
description: |
19+
Test if help for commands displays.
2020
pass_criteria:
2121
- Proper help displays for every command.
2222
"""
23-
TestRun.LOGGER.info("Run 'help' for every 'casadm' command.")
24-
output = casadm.help(shortcut)
25-
check_stdout_msg(output, casadm_help)
26-
27-
output = TestRun.executor.run("casadm" + (" -S" if shortcut else " --start-cache")
28-
+ (" -H" if shortcut else " --help"))
29-
check_stdout_msg(output, start_cache_help)
30-
31-
output = TestRun.executor.run("casadm" + (" -T" if shortcut else " --stop-cache")
32-
+ (" -H" if shortcut else " --help"))
33-
check_stdout_msg(output, stop_cache_help)
34-
35-
output = TestRun.executor.run("casadm" + (" -X" if shortcut else " --set-param")
36-
+ (" -H" if shortcut else " --help"))
37-
check_stdout_msg(output, set_params_help)
38-
39-
output = TestRun.executor.run("casadm" + (" -G" if shortcut else " --get-param")
40-
+ (" -H" if shortcut else " --help"))
41-
check_stdout_msg(output, get_params_help)
42-
43-
output = TestRun.executor.run("casadm" + (" -Q" if shortcut else " --set-cache-mode")
44-
+ (" -H" if shortcut else " --help"))
45-
check_stdout_msg(output, set_cache_mode_help)
46-
47-
output = TestRun.executor.run("casadm" + (" -A" if shortcut else " --add-core")
48-
+ (" -H" if shortcut else " --help"))
49-
check_stdout_msg(output, add_core_help)
50-
51-
output = TestRun.executor.run("casadm" + (" -R" if shortcut else " --remove-core")
52-
+ (" -H" if shortcut else " --help"))
53-
check_stdout_msg(output, remove_core_help)
54-
55-
output = TestRun.executor.run("casadm" + " --remove-detached"
56-
+ (" -H" if shortcut else " --help"))
57-
check_stdout_msg(output, remove_detached_help)
58-
59-
output = TestRun.executor.run("casadm" + (" -L" if shortcut else " --list-caches")
60-
+ (" -H" if shortcut else " --help"))
61-
check_stdout_msg(output, list_caches_help)
62-
63-
output = TestRun.executor.run("casadm" + (" -P" if shortcut else " --stats")
64-
+ (" -H" if shortcut else " --help"))
65-
check_stdout_msg(output, stats_help)
66-
67-
output = TestRun.executor.run("casadm" + (" -Z" if shortcut else " --reset-counters")
68-
+ (" -H" if shortcut else " --help"))
69-
check_stdout_msg(output, reset_counters_help)
70-
71-
output = TestRun.executor.run("casadm" + (" -F" if shortcut else " --flush-cache")
72-
+ (" -H" if shortcut else " --help"))
73-
check_stdout_msg(output, flush_cache_help)
74-
75-
output = TestRun.executor.run("casadm" + (" -C" if shortcut else " --io-class")
76-
+ (" -H" if shortcut else " --help"))
77-
check_stdout_msg(output, ioclass_help)
78-
79-
output = TestRun.executor.run("casadm" + (" -V" if shortcut else " --version")
80-
+ (" -H" if shortcut else " --help"))
81-
check_stdout_msg(output, version_help)
82-
83-
output = TestRun.executor.run("casadm" + (" -H" if shortcut else " --help")
84-
+ (" -H" if shortcut else " --help"))
85-
check_stdout_msg(output, help_help)
86-
87-
output = TestRun.executor.run("casadm" + " --standby"
88-
+ (" -H" if shortcut else " --help"))
89-
check_stdout_msg(output, standby_help)
90-
91-
output = TestRun.executor.run("casadm" + " --zero-metadata"
92-
+ (" -H" if shortcut else " --help"))
93-
check_stdout_msg(output, zero_metadata_help)
94-
95-
output = TestRun.executor.run("casadm" + (" -Y" if shortcut else " --yell")
96-
+ (" -H" if shortcut else " --help"))
97-
check_stderr_msg(output, unrecognized_stderr)
98-
check_stdout_msg(output, unrecognized_stdout)
23+
check_list_cmd = [
24+
(" -S", " --start-cache", start_cache_help),
25+
(None, " --attach-cache", attach_cache_help),
26+
(None, " --detach-cache", detach_cache_help),
27+
(" -T", " --stop-cache", stop_cache_help),
28+
(" -X", " --set-param", set_params_help),
29+
(" -G", " --get-param", get_params_help),
30+
(" -Q", " --set-cache-mode", set_cache_mode_help),
31+
(" -A", " --add-core", add_core_help),
32+
(" -R", " --remove-core", remove_core_help),
33+
(None, " --remove-inactive", remove_inactive_help),
34+
(None, " --remove-detached", remove_detached_help),
35+
(" -L", " --list-caches", list_caches_help),
36+
(" -P", " --stats", stats_help),
37+
(" -Z", " --reset-counters", reset_counters_help),
38+
(" -F", " --flush-cache", flush_cache_help),
39+
(" -C", " --io-class", ioclass_help),
40+
(" -V", " --version", version_help),
41+
# (None, " --standby", standby_help),
42+
(" -H", " --help", help_help),
43+
(None, " --zero-metadata", zero_metadata_help),
44+
]
45+
help = " -H" if shortcut else " --help"
46+
47+
with TestRun.step("Run 'help' for every 'casadm' command and check output"):
48+
for cmds in check_list_cmd:
49+
cmd = cmds[0] if shortcut else cmds[1]
50+
51+
if cmd:
52+
output = TestRun.executor.run("casadm" + cmd + help)
53+
check_stdout_msg(output, cmds[-1])
54+
55+
with TestRun.step("Run 'help' for command that doesn`t exist and check output"):
56+
cmd = " -Y" if shortcut else " --yell"
57+
output = TestRun.executor.run("casadm" + cmd + help)
58+
check_stderr_msg(output, unrecognized_stderr)
59+
check_stdout_msg(output, unrecognized_stdout)

0 commit comments

Comments
 (0)