aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/mass-pnf-sim/test_cli.py
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-20 06:34:27 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-05-20 06:34:27 -0700
commit896cc8b36cf5b0b3936f302f3b909f6ad3cfb98d (patch)
tree79edec9068e6805926180b3b36e00beb41c70125 /test/mocks/mass-pnf-sim/test_cli.py
parent50975a2d401f79a57f4a72cd6fa1b0591bf64d81 (diff)
Add tests for CLI script options
Change-Id: Iea4b353b37297e04b686d41b3494b00f61cfb9f3 Issue-ID: INT-1577 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/mass-pnf-sim/test_cli.py')
-rw-r--r--test/mocks/mass-pnf-sim/test_cli.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/mocks/mass-pnf-sim/test_cli.py b/test/mocks/mass-pnf-sim/test_cli.py
new file mode 100644
index 000000000..e47b274d3
--- /dev/null
+++ b/test/mocks/mass-pnf-sim/test_cli.py
@@ -0,0 +1,47 @@
+import MassPnfSim
+import pytest
+
+@pytest.fixture(scope="module")
+def parser():
+ return MassPnfSim.get_parser()
+
+@pytest.mark.parametrize(('expect_string, cli_opts'), [
+ ("bootstrap: error: the following arguments are required: --urlves, --ipfileserver, --typefileserver, --ipstart",
+ ['bootstrap']),
+ ("bootstrap: error: argument --typefileserver: invalid choice: 'dummy' (choose from 'sftp', 'ftps')",
+ ['bootstrap', '--typefileserver', 'dummy']),
+ ("bootstrap: error: argument --urlves: invalid_url is not a valid URL",
+ ['bootstrap', '--urlves', 'invalid_url']),
+ ("bootstrap: error: argument --ipstart: x.x.x.x is not a valid IP address",
+ ['bootstrap', '--ipstart', 'x.x.x.x']),
+ ("trigger_custom: error: the following arguments are required: --triggerstart, --triggerend",
+ ['trigger_custom'])
+ ])
+def test_subcommands(parser, capsys, expect_string, cli_opts):
+ try:
+ parser.parse_args(cli_opts)
+ except SystemExit:
+ pass
+ assert expect_string in capsys.readouterr().err
+
+@pytest.mark.parametrize(("subcommand"), [
+ 'bootstrap',
+ 'start',
+ 'stop',
+ 'trigger',
+ 'status'
+ ])
+def test_count_option(parser, capsys, subcommand):
+ try:
+ parser.parse_args([subcommand, '--count'])
+ except SystemExit:
+ pass
+ assert f"{subcommand}: error: argument --count: expected one argument" in capsys.readouterr().err
+
+def test_empty(parser, capsys):
+ try:
+ parser.parse_args([])
+ except SystemExit:
+ pass
+ assert '' is capsys.readouterr().err
+ assert '' is capsys.readouterr().out