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, --ipstart",
8 ("bootstrap: error: argument --typefileserver: invalid choice: 'dummy' (choose from 'sftp', 'ftps')",
9 ['bootstrap', '--typefileserver', 'dummy']),
10 ("bootstrap: error: argument --urlves: invalid_url is not a valid URL",
11 ['bootstrap', '--urlves', 'invalid_url']),
12 ("bootstrap: error: argument --ipstart: x.x.x.x is not a valid IP address",
13 ['bootstrap', '--ipstart', 'x.x.x.x']),
14 ("trigger_custom: error: the following arguments are required: --triggerstart, --triggerend",
17 def test_subcommands(parser, capsys, expect_string, cli_opts):
19 parser.parse_args(cli_opts)
22 assert expect_string in capsys.readouterr().err
24 def test_validate_trigger_custom(parser, caplog):
25 args = parser.parse_args(['trigger_custom', '--triggerstart', '0',
26 '--triggerend', str(SIM_INSTANCES)])
28 MassPnfSim(args).trigger_custom()
29 except SystemExit as e:
31 assert "--triggerend value greater than existing instance count" in caplog.text
34 @pytest.mark.parametrize(("subcommand"), [
41 def test_count_option(parser, capsys, subcommand):
43 parser.parse_args([subcommand, '--count'])
46 assert f"{subcommand}: error: argument --count: expected one argument" in capsys.readouterr().err
48 def test_empty(parser, capsys):
53 assert '' is capsys.readouterr().err
54 assert '' is capsys.readouterr().out