From 610f8cb59de27d8d5491c2417c74a1cb6e8f4a0e Mon Sep 17 00:00:00 2001 From: "Kieran R. Prasch" Date: Wed, 15 May 2019 19:43:56 -0600 Subject: [PATCH] Adjust Ursula CLI tests for non-federated as a default --- nucypher/cli/characters/ursula.py | 19 ++++++++++--------- tests/cli/ursula/test_federated_ursula.py | 12 ++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/nucypher/cli/characters/ursula.py b/nucypher/cli/characters/ursula.py index 5c2955d77..147c8aae7 100644 --- a/nucypher/cli/characters/ursula.py +++ b/nucypher/cli/characters/ursula.py @@ -377,16 +377,17 @@ def ursula(click_config, elif action == "view": """Paint an existing configuration to the console""" - click.secho("BLOCKCHAIN ----------\n") - painting.paint_contract_status(click_config=click_config, ursula_config=ursula_config) - current_block = URSULA.blockchain.interface.w3.eth.blockNumber - click.secho(f'Block # {current_block}') - click.secho(f'NU Balance: {URSULA.token_balance}') - click.secho(f'ETH Balance: {URSULA.eth_balance}') - click.secho(f'Current Gas Price {URSULA.blockchain.interface.w3.eth.gasPrice}') + if not URSULA.federated_only: + click.secho("BLOCKCHAIN ----------\n") + painting.paint_contract_status(click_config=click_config, ursula_config=ursula_config) + current_block = URSULA.blockchain.interface.w3.eth.blockNumber + click.secho(f'Block # {current_block}') + click.secho(f'NU Balance: {URSULA.token_balance}') + click.secho(f'ETH Balance: {URSULA.eth_balance}') + click.secho(f'Current Gas Price {URSULA.blockchain.interface.w3.eth.gasPrice}') - # TODO: Verbose status - # click.secho(f'{URSULA.blockchain.interface.w3.eth.getBlock(current_block)}') + # TODO: Verbose status + # click.secho(f'{URSULA.blockchain.interface.w3.eth.getBlock(current_block)}') click.secho("CONFIGURATION --------") response = UrsulaConfiguration._read_configuration_file(filepath=config_file or ursula_config.config_file_location) diff --git a/tests/cli/ursula/test_federated_ursula.py b/tests/cli/ursula/test_federated_ursula.py index 26371da00..44dc96a07 100644 --- a/tests/cli/ursula/test_federated_ursula.py +++ b/tests/cli/ursula/test_federated_ursula.py @@ -43,12 +43,12 @@ def test_initialize_ursula_defaults(click_runner, mocker): '--network', TEMPORARY_DOMAIN, '--federated-only') - user_input = '{ip}\n{password}\n{password}\n'.format(password=INSECURE_DEVELOPMENT_PASSWORD, ip=MOCK_IP_ADDRESS) + user_input = 'Y\n{password}\n{password}\n'.format(password=INSECURE_DEVELOPMENT_PASSWORD, ip=MOCK_IP_ADDRESS) result = click_runner.invoke(nucypher_cli, init_args, input=user_input, catch_exceptions=False) assert result.exit_code == 0 # REST Host - assert 'Enter Ursula\'s public-facing IPv4 address' in result.output + assert 'Is this the public-facing IPv4 address' in result.output # Auth assert 'Enter keyring password:' in result.output, 'WARNING: User was not prompted for password' @@ -117,7 +117,7 @@ def test_password_prompt(click_runner, custom_filepath): custom_config_filepath = os.path.join(custom_filepath, UrsulaConfiguration.CONFIG_FILENAME) assert os.path.isfile(custom_config_filepath), 'Configuration file does not exist' - view_args = ('ursula', 'view', '--config-file', custom_config_filepath) + view_args = ('ursula', 'view', '--config-file', custom_config_filepath, '--federated-only') user_input = '{}\n'.format(INSECURE_DEVELOPMENT_PASSWORD) result = click_runner.invoke(nucypher_cli, view_args, input=user_input, catch_exceptions=False, env=dict()) @@ -206,12 +206,12 @@ def test_ursula_destroy_configuration(custom_filepath, click_runner): # Run the destroy command destruction_args = ('ursula', 'destroy', '--config-file', custom_config_filepath) result = click_runner.invoke(nucypher_cli, destruction_args, - input='{}\nY\n'.format(INSECURE_DEVELOPMENT_PASSWORD), - catch_exceptions=False) + input='Y\n'.format(INSECURE_DEVELOPMENT_PASSWORD), + catch_exceptions=False, + env={'NUCYPHER_KEYRING_PASSWORD': INSECURE_DEVELOPMENT_PASSWORD}) # CLI Output assert not os.path.isfile(custom_config_filepath), 'Configuration file still exists' - assert 'password' in result.output, 'WARNING: User was not prompted for password' assert '? [y/N]:' in result.output, 'WARNING: User was not asked to destroy files' assert custom_filepath in result.output, 'WARNING: Configuration path not in output. Deleting the wrong path?' assert f'Deleted' in result.output, '"Destroyed" not in output'