From d21d7ee9477c4c2d2e7cda002c6bbd09503d9fda Mon Sep 17 00:00:00 2001 From: Kieran Prasch Date: Wed, 9 Dec 2020 14:10:03 -0800 Subject: [PATCH] Additional help text and accompanying test; Relocate help test to CLI unit. --- nucypher/cli/commands/contacts.py | 5 ++++- tests/acceptance/cli/test_card_cli.py | 10 ---------- tests/unit/cli/test_help.py | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/nucypher/cli/commands/contacts.py b/nucypher/cli/commands/contacts.py index bac0b1c70..ba60135c1 100644 --- a/nucypher/cli/commands/contacts.py +++ b/nucypher/cli/commands/contacts.py @@ -42,7 +42,10 @@ def contacts(): @click.argument('query') @click.option('--qrcode', help="Display the QR code representing a card to the console", is_flag=True, default=None) def show(query, qrcode): - """View existing character card""" + """ + Lookup and view existing character card + QUERY can be either the card id or nickname. + """ emitter = StdoutEmitter() try: card = select_card(emitter=emitter, card_identifier=query) diff --git a/tests/acceptance/cli/test_card_cli.py b/tests/acceptance/cli/test_card_cli.py index cdcad6c96..40e744994 100644 --- a/tests/acceptance/cli/test_card_cli.py +++ b/tests/acceptance/cli/test_card_cli.py @@ -22,7 +22,6 @@ import tempfile from pathlib import Path from umbral.keys import UmbralPrivateKey -from nucypher.cli.commands.contacts import contacts from nucypher.cli.main import nucypher_cli from nucypher.policy.identity import Card @@ -63,15 +62,6 @@ def bob_encrypting_key(): return UmbralPrivateKey.gen_key().get_pubkey().hex() - -def test_contacts_help(click_runner): - command = ('contacts', '--help') - result = click_runner.invoke(nucypher_cli, command, catch_exceptions=False) - assert result.exit_code == 0, result.output - normalized_help_text = ' '.join(result.output.split()) - assert contacts.__doc__ in normalized_help_text - - def test_list_cards_with_none_created(click_runner, certificates_tempdir): command = ('contacts', 'list') result = click_runner.invoke(nucypher_cli, command, catch_exceptions=False) diff --git a/tests/unit/cli/test_help.py b/tests/unit/cli/test_help.py index 8156b87f3..e2657e09d 100644 --- a/tests/unit/cli/test_help.py +++ b/tests/unit/cli/test_help.py @@ -15,11 +15,13 @@ You should have received a copy of the GNU Affero General Public License along with nucypher. If not, see . """ + import click import pytest import nucypher from nucypher.blockchain.eth.sol.__conf__ import SOLIDITY_COMPILER_VERSION +from nucypher.cli.commands.contacts import contacts, show from nucypher.cli.commands.deploy import deploy from nucypher.cli.main import ENTRY_POINTS, nucypher_cli from nucypher.config.constants import USER_LOG_DIR, DEFAULT_CONFIG_ROOT @@ -93,3 +95,20 @@ def test_echo_logging_root(click_runner): result = click_runner.invoke(nucypher_cli, version_args, catch_exceptions=False) assert result.exit_code == 0 assert USER_LOG_DIR in result.output, 'Log path text was not produced.' + + +def test_contacts_help(click_runner): + command = ('contacts', '--help') + result = click_runner.invoke(nucypher_cli, command, catch_exceptions=False) + assert result.exit_code == 0, result.output + normalized_help_text = ' '.join(result.output.split()) + assert contacts.__doc__ in normalized_help_text + + +def test_contacts_show_help(click_runner): + command = ('contacts', 'show', '--help') + result = click_runner.invoke(nucypher_cli, command, catch_exceptions=False) + assert result.exit_code == 0, result.output + normalized_help_text = ' '.join(result.output.split()) + normalized_docstring = ' '.join(show.__doc__.split()) + assert normalized_docstring in normalized_help_text