From df5004b094fb34c72eb7c96961a466a2b6f69f22 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Fri, 5 Jun 2020 11:32:44 +0200 Subject: Add test case for invalid '--count' option value Change-Id: Ib46c26889f01ce0cd9d90865070d5c5ac9b5d08a Issue-ID: INT-1613 Signed-off-by: Bartek Grzybowski --- test/mocks/mass-pnf-sim/test_cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/mocks/mass-pnf-sim/test_cli.py b/test/mocks/mass-pnf-sim/test_cli.py index f574a725d..0f464167a 100644 --- a/test/mocks/mass-pnf-sim/test_cli.py +++ b/test/mocks/mass-pnf-sim/test_cli.py @@ -39,12 +39,30 @@ def test_validate_trigger_custom(parser, caplog): 'status' ]) def test_count_option(parser, capsys, subcommand): + '''Test case where no arg passed to '--count' opt''' try: parser.parse_args([subcommand, '--count']) except SystemExit: pass assert f"{subcommand}: error: argument --count: expected one argument" in capsys.readouterr().err +@pytest.mark.parametrize(("subcommand"), [ + 'start', + 'stop', + 'trigger', + 'status' + ]) +def test_count_option_bad_value(parser, caplog, subcommand): + '''Test case where invalid value passed to '--count' opt''' + try: + args = parser.parse_args([subcommand, '--count', str(SIM_INSTANCES + 1)]) + m = getattr(MassPnfSim(args), subcommand) + m() + except SystemExit: + pass + assert '--count value greater that existing instance count' in caplog.text + caplog.clear() + def test_empty(parser, capsys): try: parser.parse_args([]) -- cgit 1.2.3-korg