Additional help text and accompanying test; Relocate help test to CLI unit.

pull/2115/head
Kieran Prasch 2020-12-09 14:10:03 -08:00
parent b342180d89
commit d21d7ee947
3 changed files with 23 additions and 11 deletions

View File

@ -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)

View File

@ -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)

View File

@ -15,11 +15,13 @@ You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
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