mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Fix bug related to config overwrite
This commit is contained in:
parent
4a0a92645d
commit
bd6e16b836
@ -45,7 +45,7 @@ def run_configure(args, skip_if_exists=False):
|
|||||||
if config_file_exists and not args.yes:
|
if config_file_exists and not args.yes:
|
||||||
want = input('Config file `{}` exists, do you want to override it? '
|
want = input('Config file `{}` exists, do you want to override it? '
|
||||||
'(cannot be undone) [y/n]: '.format(config_path))
|
'(cannot be undone) [y/n]: '.format(config_path))
|
||||||
if not want:
|
if want != 'y':
|
||||||
return
|
return
|
||||||
|
|
||||||
# Patch the default configuration with the new values
|
# Patch the default configuration with the new values
|
||||||
|
@ -144,3 +144,22 @@ def test_run_configure_when_config_does_not_exist(monkeypatch,
|
|||||||
args = Namespace(config='foo', yes=True)
|
args = Namespace(config='foo', yes=True)
|
||||||
return_value = run_configure(args)
|
return_value = run_configure(args)
|
||||||
assert return_value is None
|
assert return_value is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_configure_when_config_does_exist(monkeypatch,
|
||||||
|
mock_write_config,
|
||||||
|
mock_generate_key_pair,
|
||||||
|
mock_bigchaindb_backup_config):
|
||||||
|
value = {}
|
||||||
|
def mock_write_config(newconfig, filename=None):
|
||||||
|
value['return'] = newconfig
|
||||||
|
|
||||||
|
from bigchaindb.commands.bigchain import run_configure
|
||||||
|
monkeypatch.setattr('os.path.exists', lambda path: True)
|
||||||
|
monkeypatch.setattr('builtins.input', lambda question: '\n')
|
||||||
|
monkeypatch.setattr('bigchaindb.config_utils.write_config', mock_write_config)
|
||||||
|
|
||||||
|
args = Namespace(config='foo', yes=None)
|
||||||
|
run_configure(args)
|
||||||
|
assert value == {}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import pytest
|
|||||||
import bigchaindb
|
import bigchaindb
|
||||||
|
|
||||||
|
|
||||||
ORIGINAL_CONFIG = copy.deepcopy(bigchaindb.config)
|
ORIGINAL_CONFIG = copy.deepcopy(bigchaindb._config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user