def config(general_config, config_options, config_file, force, action): """ View and optionally update the Ursula node's configuration. \b Sub-Commands ~~~~~~~~~~~~~ ip-address - automatically detect and configure the external IP address. """ emitter = setup_emitter(general_config, config_options.worker_address) if not config_file: config_file = select_config_file( emitter=emitter, checksum_address=config_options.worker_address, config_class=UrsulaConfiguration) if action == 'ip-address': rest_host = collect_worker_ip_address(emitter=emitter, network=config_options.domain, force=force) config_options.rest_host = rest_host elif action: emitter.echo(f'"{action}" is not a valid command.', color='red') raise click.Abort() updates = config_options.get_updates() get_or_update_configuration(emitter=emitter, config_class=UrsulaConfiguration, filepath=config_file, updates=updates)
def config(general_config, config_file, config_options): """View and optionally update existing StakeHolder's configuration.""" emitter = setup_emitter(general_config) configuration_file_location = config_file or StakeHolderConfiguration.default_filepath() updates = config_options.get_updates() get_or_update_configuration(emitter=emitter, config_class=StakeHolderConfiguration, filepath=configuration_file_location, updates=updates)
def test_update_configuration_cli_action(config, test_emitter, test_registry_source_manager, capsys): config_class, config_file = config.__class__, config.filepath updates = dict(federated_only=True) get_or_update_configuration(emitter=test_emitter, config_class=config_class, filepath=config_file, updates=updates) config.update.assert_called_once_with(**updates) configure.handle_invalid_configuration_file.assert_not_called() configure.handle_missing_configuration_file.assert_not_called() captured = capsys.readouterr() assert SUCCESSFUL_UPDATE_CONFIGURATION_VALUES.format(fields='federated_only') in captured.out
def config(general_config, config_file, full_config_options): """View and optionally update existing Alice's configuration.""" emitter = setup_emitter(general_config) if not config_file: config_file = select_config_file(emitter=emitter, checksum_address=full_config_options.config_options.pay_with, config_class=AliceConfiguration) updates = full_config_options.get_updates() get_or_update_configuration(emitter=emitter, config_class=AliceConfiguration, filepath=config_file, updates=updates)
def config(general_config, config_options, config_file): """View and optionally update existing Bob's configuration.""" emitter = setup_emitter(general_config) if not config_file: config_file = select_config_file(emitter=emitter, checksum_address=config_options.checksum_address, config_class=BobConfiguration) updates = config_options.get_updates() get_or_update_configuration(emitter=emitter, config_class=BobConfiguration, filepath=config_file, updates=updates)
def config(general_config, config_options, config_file): """View and optionally update the Ursula node's configuration.""" emitter = setup_emitter(general_config, config_options.worker_address) if not config_file: config_file = select_config_file(emitter=emitter, checksum_address=config_options.worker_address, config_class=UrsulaConfiguration) updates = config_options.get_updates() get_or_update_configuration(emitter=emitter, config_class=UrsulaConfiguration, filepath=config_file, updates=updates)
def test_handle_update_missing_configuration_file_cli_action(config, test_emitter, test_registry_source_manager, mocker): config_class, config_file = config.__class__, config.filepath mocker.patch.object(config_class, '_read_configuration_file', side_effect=FileNotFoundError) updates = dict(federated_only=True) with pytest.raises(click.FileError): get_or_update_configuration(emitter=test_emitter, config_class=config_class, filepath=config_file, updates=updates) configure.handle_missing_configuration_file.assert_called() config._write_configuration_file.assert_not_called() configure.handle_invalid_configuration_file.assert_not_called()
def config(general_config, config_options, config_file, force, action): """View and optionally update the Ursula node's configuration.""" emitter = setup_emitter(general_config, config_options.worker_address) if not config_file: config_file = select_config_file( emitter=emitter, checksum_address=config_options.worker_address, config_class=UrsulaConfiguration) if action == 'ip-address': rest_host = collect_worker_ip_address(emitter=emitter, network=config_options.domain, force=force) config_options.rest_host = rest_host updates = config_options.get_updates() get_or_update_configuration(emitter=emitter, config_class=UrsulaConfiguration, filepath=config_file, updates=updates)
def test_handle_update_invalid_configuration_file_cli_action(config, test_emitter, test_registry_source_manager, mocker, capsys): config_class = config.__class__ config_file = config.filepath mocker.patch.object(config_class, '_read_configuration_file', side_effect=config_class.ConfigurationError) updates = dict(federated_only=True) with pytest.raises(config_class.ConfigurationError): get_or_update_configuration(emitter=test_emitter, config_class=config_class, filepath=config_file, updates=updates) configure.handle_missing_configuration_file.assert_not_called() config._write_configuration_file.assert_not_called() configure.handle_invalid_configuration_file.assert_called() captured = capsys.readouterr() assert INVALID_CONFIGURATION_FILE_WARNING.format(filepath=config_file) in captured.out