Separate YES/NO (w/o linebreak) and YES_ENTER/NO_ENTER (with linebreak) in test constants

pull/2033/head
Bogdan Opanchuk 2020-05-24 12:48:16 -07:00
parent 844355b5fa
commit 8b9d559113
4 changed files with 17 additions and 15 deletions

View File

@ -28,7 +28,7 @@ from nucypher.config.constants import APP_DIR, DEFAULT_CONFIG_ROOT, NUCYPHER_ENV
from tests.constants import (
FAKE_PASSWORD_CONFIRMED, INSECURE_DEVELOPMENT_PASSWORD,
MOCK_CUSTOM_INSTALLATION_PATH,
MOCK_IP_ADDRESS, YES)
MOCK_IP_ADDRESS, YES_ENTER)
from tests.utils.ursula import MOCK_URSULA_STARTING_PORT
@ -41,7 +41,7 @@ def test_initialize_ursula_defaults(click_runner, mocker):
# Use default ursula init args
init_args = ('ursula', 'init', '--network', TEMPORARY_DOMAIN, '--federated-only')
user_input = YES + FAKE_PASSWORD_CONFIRMED
user_input = YES_ENTER + FAKE_PASSWORD_CONFIRMED
result = click_runner.invoke(nucypher_cli, init_args, input=user_input, catch_exceptions=False)
assert result.exit_code == 0

View File

@ -37,7 +37,7 @@ from tests.constants import (
INSECURE_DEVELOPMENT_PASSWORD,
MOCK_IP_ADDRESS,
TEST_PROVIDER_URI,
YES
YES_ENTER
)
from tests.utils.ursula import MOCK_URSULA_STARTING_PORT, start_pytest_ursula_services
@ -57,7 +57,7 @@ def test_ursula_rest_host_determination(click_runner, mocker):
mocker.patch.object(UrsulaConfiguration, 'to_configuration_file', return_value=None)
args = ('ursula', 'init', '--federated-only', '--network', TEMPORARY_DOMAIN)
user_input = YES + FAKE_PASSWORD_CONFIRMED
user_input = YES_ENTER + FAKE_PASSWORD_CONFIRMED
result = click_runner.invoke(nucypher_cli, args, catch_exceptions=False, input=user_input)
assert result.exit_code == 0
assert MOCK_IP_ADDRESS in result.output

View File

@ -139,9 +139,11 @@ PYEVM_GAS_LIMIT = TEST_GAS_LIMIT # TODO: move elsewhere (used to set pyevm gas
# CLI
#
YES = 'Y\n'
YES = 'Y'
YES_ENTER = YES + '\n'
NO = 'N\n'
NO = 'N'
NO_ENTER = NO + '\n'
FAKE_PASSWORD_CONFIRMED = '{password}\n{password}\n'.format(password=INSECURE_DEVELOPMENT_PASSWORD)

View File

@ -27,7 +27,7 @@ from nucypher.blockchain.eth.interfaces import BlockchainInterface
from nucypher.blockchain.eth.token import NU
from nucypher.cli.commands.worklock import worklock
from nucypher.config.constants import TEMPORARY_DOMAIN
from tests.constants import CLI_TEST_ENV, MOCK_PROVIDER_URI, YES, NO
from tests.constants import CLI_TEST_ENV, MOCK_PROVIDER_URI, YES_ENTER, NO_ENTER
from tests.mock.agents import MockContractAgent
from nucypher.cli.literature import CONFIRM_BID_VERIFICATION
@ -81,7 +81,7 @@ def test_bid_too_soon(click_runner,
a_month_too_soon = now-(3600*30)
mocker.patch.object(BlockchainInterface, 'get_blocktime', return_value=a_month_too_soon)
with pytest.raises(Bidder.BiddingIsClosed):
result = click_runner.invoke(worklock, bidding_command, catch_exceptions=False, input=YES, env=CLI_TEST_ENV)
result = click_runner.invoke(worklock, bidding_command, catch_exceptions=False, input=YES_ENTER, env=CLI_TEST_ENV)
assert result.exit_code != 0
@ -99,7 +99,7 @@ def test_bid_too_late(click_runner,
a_month_too_late = now+(3600*30)
mocker.patch.object(BlockchainInterface, 'get_blocktime', return_value=a_month_too_late)
with pytest.raises(Bidder.BiddingIsClosed):
result = click_runner.invoke(worklock, bidding_command, catch_exceptions=False, input=YES, env=CLI_TEST_ENV)
result = click_runner.invoke(worklock, bidding_command, catch_exceptions=False, input=YES_ENTER, env=CLI_TEST_ENV)
assert result.exit_code != 0
@ -130,7 +130,7 @@ def test_valid_bid(click_runner,
'--network', TEMPORARY_DOMAIN,
'--force')
result = click_runner.invoke(worklock, command, catch_exceptions=False, input=YES, env=CLI_TEST_ENV)
result = click_runner.invoke(worklock, command, catch_exceptions=False, input=YES_ENTER, env=CLI_TEST_ENV)
assert result.exit_code == 0
# OK - Let's see what happened
@ -166,7 +166,7 @@ def test_cancel_bid(click_runner,
'--provider', MOCK_PROVIDER_URI,
'--network', TEMPORARY_DOMAIN,
'--force')
result = click_runner.invoke(worklock, command, input=YES, env=CLI_TEST_ENV, catch_exceptions=False)
result = click_runner.invoke(worklock, command, input=YES_ENTER, env=CLI_TEST_ENV, catch_exceptions=False)
assert result.exit_code == 0
# Bidder
@ -234,7 +234,7 @@ def test_enable_claiming(click_runner,
gas_limit_1 = 200000
gas_limit_2 = 300000
user_input = YES + YES + str(gas_limit_1) + '\n' + NO + str(gas_limit_2) + '\n' + YES
user_input = YES_ENTER + YES_ENTER + str(gas_limit_1) + '\n' + NO_ENTER + str(gas_limit_2) + '\n' + YES_ENTER
result = click_runner.invoke(worklock, command, input=user_input, env=CLI_TEST_ENV, catch_exceptions=False)
assert result.exit_code == 0
confirmation = CONFIRM_BID_VERIFICATION.format(bidder_address=surrogate_bidder.checksum_address,
@ -305,7 +305,7 @@ def test_initial_claim(click_runner,
'--network', TEMPORARY_DOMAIN,
'--force')
result = click_runner.invoke(worklock, command, input=YES, env=CLI_TEST_ENV, catch_exceptions=False)
result = click_runner.invoke(worklock, command, input=YES_ENTER, env=CLI_TEST_ENV, catch_exceptions=False)
assert result.exit_code == 0
mock_worklock_agent.claim.assert_called_once_with(checksum_address=surrogate_bidder.checksum_address)
@ -352,7 +352,7 @@ def test_already_claimed(click_runner,
'--network', TEMPORARY_DOMAIN,
'--force')
result = click_runner.invoke(worklock, command, input=YES, env=CLI_TEST_ENV, catch_exceptions=False)
result = click_runner.invoke(worklock, command, input=YES_ENTER, env=CLI_TEST_ENV, catch_exceptions=False)
assert result.exit_code == 1 # TODO: Decide if this case should error (like now) or simply do nothing
# Bidder
@ -408,7 +408,7 @@ def test_refund(click_runner,
'--network', TEMPORARY_DOMAIN,
'--force')
result = click_runner.invoke(worklock, command, input=YES, env=CLI_TEST_ENV, catch_exceptions=False)
result = click_runner.invoke(worklock, command, input=YES_ENTER, env=CLI_TEST_ENV, catch_exceptions=False)
assert result.exit_code == 0
# Bidder