From e82ee8e024f45c868072c7bf2a3a85070b5269c3 2018-02-26 23:31:37 From: Branko Majic Date: 2018-02-26 23:31:37 Subject: [PATCH] GC-11: Expanded help to include some more information on tool usage. --- diff --git a/functional_tests/test_help.py b/functional_tests/test_help.py index 56c1f45851d6411a124b45200fd8ab9b9123e915..6c54e2b51e4a3ab2216c81bf745798cac39b4cc8 100644 --- a/functional_tests/test_help.py +++ b/functional_tests/test_help.py @@ -57,3 +57,26 @@ def test_usage_help_shown(): assert "usage: gimmecert [-h]" in stdout assert stderr == '' assert process.returncode == 0 + + +def test_extended_help_shown(): + # John is still not quite sure how the tool works. Therefore he + # decides to try out the -h flag to the command. + process = subprocess.Popen(["gimmecert", "-h"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = process.communicate() + stdout, stderr = stdout.decode(), stderr.decode() + + # In doing so, John is presented with much more extensive + # instructions that provide him with better idea on how to use the + # tool. + assert stderr == '' + assert process.returncode == 0 + assert "usage: gimmecert [-h]" in stdout + assert "Examples:" in stdout + assert "optional arguments" in stdout + # @TODO: Can't really test this without producing errors, but + # possibly not needed. + # assert "positional arguments" in stdout + # @TODO: Can't test at the moment, should be added once the first + # commands is implemented. + # assert "command1|command2" in stdout diff --git a/gimmecert/cli.py b/gimmecert/cli.py index 2d69bc19ed103156795f77aa7f13206986415d7e..908f794f4fb03e2ff9ac0af5e79b22cefdbd7da0 100644 --- a/gimmecert/cli.py +++ b/gimmecert/cli.py @@ -25,6 +25,8 @@ import argparse DESCRIPTION = """\ Issues server and client X.509 certificates using a local CA hierarchy. + +Examples: """ diff --git a/tests/test_cli.py b/tests/test_cli.py index 14e4d3bc70d612e149ac35aa8d585a2f665cf0a8..ef2922ce99aa71d1ec9bfd3b34ad2d0a86c758af 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -82,3 +82,9 @@ def test_main_invokes_parser_function(mock_get_parser): gimmecert.cli.main() mock_args.func.assert_called_once_with(mock_args) + + +def test_parser_help_contains_examples(): + parser = gimmecert.cli.get_parser() + + assert 'Examples' in parser.description