2022-11-16 13:13:53 +00:00
|
|
|
|
2020-05-22 13:07:41 +00:00
|
|
|
|
2020-05-15 18:27:04 +00:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from nucypher.blockchain.eth.networks import NetworksInventory
|
|
|
|
from nucypher.cli.actions.select import select_network
|
|
|
|
|
|
|
|
|
2022-04-13 18:04:26 +00:00
|
|
|
__POLY_NETWORKS = NetworksInventory.POLY_NETWORKS
|
|
|
|
__ETH_NETWORKS = NetworksInventory.ETH_NETWORKS
|
2020-05-15 19:45:56 +00:00
|
|
|
|
|
|
|
|
2022-04-13 18:04:26 +00:00
|
|
|
@pytest.mark.parametrize('user_input', range(0, len(__ETH_NETWORKS)-1))
|
|
|
|
def test_select_network_cli_action_eth(test_emitter, capsys, mock_stdin, user_input):
|
2020-05-24 20:23:49 +00:00
|
|
|
mock_stdin.line(str(user_input))
|
2022-04-13 18:04:26 +00:00
|
|
|
selection = __ETH_NETWORKS[user_input]
|
|
|
|
result = select_network(emitter=test_emitter, network_type=NetworksInventory.ETH)
|
2020-05-15 18:27:04 +00:00
|
|
|
assert result == selection
|
2022-04-13 18:04:26 +00:00
|
|
|
assert result not in __POLY_NETWORKS
|
2020-05-24 19:35:07 +00:00
|
|
|
captured = capsys.readouterr()
|
2022-04-13 18:04:26 +00:00
|
|
|
for name in __ETH_NETWORKS:
|
2020-05-24 19:35:07 +00:00
|
|
|
assert name in captured.out
|
2020-05-24 20:23:49 +00:00
|
|
|
assert mock_stdin.empty()
|
2022-04-13 18:04:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_select_network_cli_action_neither(test_emitter):
|
|
|
|
with pytest.raises(Exception):
|
|
|
|
select_network(emitter=test_emitter, network_type="FAKE COIN")
|