From f9c609ff0d34cd21ab40e24acb1fe70c833ff062 Mon Sep 17 00:00:00 2001 From: vrde Date: Tue, 26 Apr 2016 03:24:56 +0200 Subject: [PATCH] Add env variables to default config --- bigchaindb/commands/bigchain.py | 5 ++++- bigchaindb/config_utils.py | 6 +++++- setup.py | 2 +- tests/test_commands.py | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bigchaindb/commands/bigchain.py b/bigchaindb/commands/bigchain.py index d6c6a0c6..f4e25f5e 100644 --- a/bigchaindb/commands/bigchain.py +++ b/bigchaindb/commands/bigchain.py @@ -52,6 +52,8 @@ def run_configure(args, skip_if_exists=False): skip_if_exists (bool): skip the function if a config file already exists """ config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH + bigchaindb.config_utils.autoconfigure(filename=False, force=True) + config_file_exists = False # if the config path is `-` then it's stdout @@ -68,7 +70,8 @@ def run_configure(args, skip_if_exists=False): return # Patch the default configuration with the new values - conf = copy.deepcopy(bigchaindb._config) + conf = copy.deepcopy(bigchaindb.config) + del conf['CONFIGURED'] print('Generating keypair', file=sys.stderr) conf['keypair']['private'], conf['keypair']['public'] = \ diff --git a/bigchaindb/config_utils.py b/bigchaindb/config_utils.py index 3ec17656..4256f580 100644 --- a/bigchaindb/config_utils.py +++ b/bigchaindb/config_utils.py @@ -91,7 +91,11 @@ def file_config(filename=None): file at CONFIG_DEFAULT_PATH, if filename == None) """ logger.debug('On entry into file_config(), filename = {}'.format(filename)) - if not filename: + + if filename is False: + return {} + + if filename is None: filename = CONFIG_DEFAULT_PATH logger.debug('file_config() will try to open `{}`'.format(filename)) diff --git a/setup.py b/setup.py index 77e3a02d..2cbc2d35 100644 --- a/setup.py +++ b/setup.py @@ -73,7 +73,7 @@ setup( ] }, install_requires=[ - 'rethinkdb==2.2.0.post4', + 'rethinkdb==2.3.0', 'pysha3==0.3', 'pytz==2015.7', 'cryptoconditions==0.1.6', diff --git a/tests/test_commands.py b/tests/test_commands.py index ba0b9f24..f7e27a2d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -186,7 +186,7 @@ def test_run_configure_when_config_does_not_exist(monkeypatch, mock_bigchaindb_backup_config): from bigchaindb.commands.bigchain import run_configure monkeypatch.setattr('os.path.exists', lambda path: False) - monkeypatch.setattr('builtins.input', lambda question: '\n') + monkeypatch.setattr('builtins.input', lambda: '\n') args = Namespace(config='foo', yes=True) return_value = run_configure(args) assert return_value is None @@ -202,7 +202,7 @@ def test_run_configure_when_config_does_exist(monkeypatch, from bigchaindb.commands.bigchain import run_configure monkeypatch.setattr('os.path.exists', lambda path: True) - monkeypatch.setattr('builtins.input', lambda question: '\n') + monkeypatch.setattr('builtins.input', lambda: '\n') monkeypatch.setattr('bigchaindb.config_utils.write_config', mock_write_config) args = Namespace(config='foo', yes=None)