|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
9 | | -from api.cas import casadm |
10 | 9 | from api.cas.cli_help_messages import * |
11 | 10 | from api.cas.cli_messages import check_stderr_msg, check_stdout_msg |
12 | 11 | from core.test_run import TestRun |
13 | 12 |
|
14 | 13 |
|
15 | | -@pytest.mark.parametrize("shortcut", [True, False]) |
| 14 | +@pytest.mark.parametrizex("shortcut", [True, False]) |
16 | 15 | def test_cli_help(shortcut): |
17 | 16 | """ |
18 | 17 | title: Test for 'help' command. |
19 | | - description: Test if help for commands displays. |
| 18 | + description: | |
| 19 | + Test if help for commands displays. |
20 | 20 | pass_criteria: |
21 | 21 | - Proper help displays for every command. |
22 | 22 | """ |
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