From a5a3b8f76b6e5c710efb67a739e3cddf78fbc242 Mon Sep 17 00:00:00 2001 From: Neetha John Date: Tue, 22 Jun 2021 15:28:56 -0700 Subject: [PATCH 1/2] Fix the return code for invalid option case Signed-off-by: Neetha John --- pfcwd/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index 1f8ec2293e..c3b92fd223 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -242,7 +242,7 @@ def start(self, action, restoration_time, ports, detection_time): click.echo("Failed to run command, invalid options:") for opt in invalid_ports: click.echo(opt) - exit() + exit(1) self.start_cmd(action, restoration_time, ports, detection_time) From ca0e60f06e8a648700e62e9955017119250fe54d Mon Sep 17 00:00:00 2001 From: Neetha John Date: Tue, 22 Jun 2021 15:29:22 -0700 Subject: [PATCH 2/2] Check for the correct return code in unit test Signed-off-by: Neetha John --- tests/pfcwd_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/pfcwd_test.py b/tests/pfcwd_test.py index b0af050233..c150c0568b 100644 --- a/tests/pfcwd_test.py +++ b/tests/pfcwd_test.py @@ -255,7 +255,7 @@ def test_pfcwd_start_ports_invalid(self): obj=db ) print(result.output) - assert result.exit_code == 0 + assert result.exit_code == 1 assert result.output == pfcwd_show_start_config_output_fail @classmethod @@ -447,7 +447,7 @@ def test_pfcwd_start_ports_masic_invalid(self): obj=db ) print(result.output) - assert result.exit_code == 0 + assert result.exit_code == 1 assert result.output == show_pfc_config_start_fail # get config after the command, config shouldn't change @@ -500,4 +500,4 @@ def teardown_class(cls): import mock_tables.mock_single_asic importlib.reload(mock_tables.mock_single_asic) import pfcwd.main - importlib.reload(pfcwd.main) \ No newline at end of file + importlib.reload(pfcwd.main)