From bde7eea3315ba06b017105c83da1b61a12dea058 Mon Sep 17 00:00:00 2001 From: Jia Chengkun Date: Thu, 23 Apr 2015 16:32:48 +0800 Subject: [PATCH 1/3] update arg_parser.py to fix `--port` argument type --- src/ianitor/args_parser.py | 1 + tests/test_args_parser.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/ianitor/args_parser.py b/src/ianitor/args_parser.py index 1249400..cc380d9 100644 --- a/src/ianitor/args_parser.py +++ b/src/ianitor/args_parser.py @@ -143,6 +143,7 @@ def get_parser(): parser.add_argument( "--port", + type=int, default=0, help="set service port", ) diff --git a/tests/test_args_parser.py b/tests/test_args_parser.py index 99ef445..d2a5692 100644 --- a/tests/test_args_parser.py +++ b/tests/test_args_parser.py @@ -52,3 +52,9 @@ def test_parse_args(): def test_default_heartbeat(): args, invocation = args_parser.parse_args() assert args.heartbeat == TEST_TTL / 10. + + +@patch('sys.argv', ["ianitor", "tailf", '--port', '1234', '--', 'tail', '-f', 'something']) # noqa +def test_default_heartbeat(): + args, invocation = args_parser.parse_args() + assert args.port == 1234 From 94aa37ba7119227cdb6ef0a5f7b6297a1cca1fe1 Mon Sep 17 00:00:00 2001 From: Jia Chengkun Date: Thu, 23 Apr 2015 16:51:13 +0800 Subject: [PATCH 2/3] rename the test case in test_args_parser.py --- tests/test_args_parser.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_args_parser.py b/tests/test_args_parser.py index d2a5692..3896ab9 100644 --- a/tests/test_args_parser.py +++ b/tests/test_args_parser.py @@ -45,6 +45,12 @@ def test_parse_args(): args, invocation = args_parser.parse_args() assert invocation == ['tail', '-f', 'something'] + +@patch('sys.argv', ["ianitor", "tailf", '--port', '1234', '--', 'tail', '-f', 'something']) # noqa +def test_parse_port(): + args, invocation = args_parser.parse_args() + assert args.port == 1234 + TEST_TTL = 100 @@ -52,9 +58,3 @@ def test_parse_args(): def test_default_heartbeat(): args, invocation = args_parser.parse_args() assert args.heartbeat == TEST_TTL / 10. - - -@patch('sys.argv', ["ianitor", "tailf", '--port', '1234', '--', 'tail', '-f', 'something']) # noqa -def test_default_heartbeat(): - args, invocation = args_parser.parse_args() - assert args.port == 1234 From d7abdf0b317b69ad84e2470222b0f92c3f53015e Mon Sep 17 00:00:00 2001 From: Jia Chengkun Date: Thu, 23 Apr 2015 16:55:23 +0800 Subject: [PATCH 3/3] remove the defualt value of argument of `--port` --- src/ianitor/args_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ianitor/args_parser.py b/src/ianitor/args_parser.py index cc380d9..e0107f4 100644 --- a/src/ianitor/args_parser.py +++ b/src/ianitor/args_parser.py @@ -143,7 +143,7 @@ def get_parser(): parser.add_argument( "--port", - type=int, default=0, + type=int, help="set service port", )