2 from MassPnfSim import MassPnfSim
3 from test_settings import SIM_INSTANCES
5 @pytest.mark.parametrize(('expect_string, cli_opts'), [
6 ("bootstrap: error: the following arguments are required: --urlves, --ipfileserver, --typefileserver, " +\
7 "--user, --password, --ipstart",
9 ("bootstrap: error: argument --typefileserver: invalid choice: 'dummy' (choose from 'sftp', 'ftps')",
10 ['bootstrap', '--typefileserver', 'dummy']),
11 ("bootstrap: error: argument --urlves: invalid_url is not a valid URL",
12 ['bootstrap', '--urlves', 'invalid_url']),
13 ("bootstrap: error: argument --ipstart: x.x.x.x is not a valid IP address",
14 ['bootstrap', '--ipstart', 'x.x.x.x']),
15 ("trigger_custom: error: the following arguments are required: --triggerstart, --triggerend",
18 def test_subcommands(parser, capsys, expect_string, cli_opts):
20 parser.parse_args(cli_opts)
23 assert expect_string in capsys.readouterr().err
25 def test_validate_trigger_custom(parser, caplog):
26 args = parser.parse_args(['trigger_custom', '--triggerstart', '0',
27 '--triggerend', str(SIM_INSTANCES)])
29 MassPnfSim().trigger_custom(args)
30 except SystemExit as e:
32 assert "--triggerend value greater than existing instance count" in caplog.text
35 @pytest.mark.parametrize(("subcommand"), [
43 def test_count_option(parser, capsys, subcommand):
44 '''Test case where no arg passed to '--count' opt'''
46 parser.parse_args([subcommand, '--count'])
49 assert f"{subcommand}: error: argument --count: expected one argument" in capsys.readouterr().err
51 @pytest.mark.parametrize(("subcommand"), [
58 def test_count_option_bad_value(parser, caplog, subcommand):
59 '''Test case where invalid value passed to '--count' opt'''
61 args = parser.parse_args([subcommand, '--count', str(SIM_INSTANCES + 1)])
62 m = getattr(MassPnfSim(), subcommand)
66 assert '--count value greater that existing instance count' in caplog.text
69 def test_empty(parser, capsys):
74 assert '' is capsys.readouterr().err
75 assert '' is capsys.readouterr().out