mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Force a config reset before every test
This commit is contained in:
parent
ff2e36a44e
commit
22923ee9d3
@ -185,15 +185,14 @@ def autoconfigure(filename=None, config=None, force=False):
|
|||||||
|
|
||||||
newconfig = env_config(bigchaindb.config)
|
newconfig = env_config(bigchaindb.config)
|
||||||
|
|
||||||
if config:
|
|
||||||
newconfig = update(newconfig, config)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# import pdb; pdb.set_trace()
|
|
||||||
newconfig = update(newconfig, file_config(filename=filename))
|
newconfig = update(newconfig, file_config(filename=filename))
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
logger.warning('Cannot find config file `%s`.' % e.filename)
|
logger.warning('Cannot find config file `%s`.' % e.filename)
|
||||||
|
|
||||||
|
if config:
|
||||||
|
newconfig = update(newconfig, config)
|
||||||
|
|
||||||
dict_config(newconfig)
|
dict_config(newconfig)
|
||||||
return newconfig
|
return newconfig
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ def ignore_local_config_file(monkeypatch):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def restore_config(request, node_config):
|
def restore_config(request, node_config):
|
||||||
from bigchaindb import config_utils
|
from bigchaindb import config_utils
|
||||||
config_utils.dict_config(node_config)
|
config_utils.dict_config(node_config)
|
||||||
|
@ -94,15 +94,18 @@ def test_bigchain_run_start_assume_yes_create_default_config(monkeypatch, mock_p
|
|||||||
# TODO Please beware, that if debugging, the "-s" switch for pytest will
|
# TODO Please beware, that if debugging, the "-s" switch for pytest will
|
||||||
# interfere with capsys.
|
# interfere with capsys.
|
||||||
# See related issue: https://github.com/pytest-dev/pytest/issues/128
|
# See related issue: https://github.com/pytest-dev/pytest/issues/128
|
||||||
|
@pytest.mark.usefixtures('restore_config')
|
||||||
def test_bigchain_show_config(capsys):
|
def test_bigchain_show_config(capsys):
|
||||||
from bigchaindb import config
|
from bigchaindb import config
|
||||||
from bigchaindb.commands.bigchain import run_show_config
|
from bigchaindb.commands.bigchain import run_show_config
|
||||||
|
|
||||||
args = Namespace(config=None)
|
args = Namespace(config=None)
|
||||||
_, _ = capsys.readouterr()
|
_, _ = capsys.readouterr()
|
||||||
run_show_config(args)
|
run_show_config(args)
|
||||||
output_config, _ = capsys.readouterr()
|
output_config = json.loads(capsys.readouterr()[0])
|
||||||
del config['CONFIGURED']
|
del config['CONFIGURED']
|
||||||
assert output_config.strip() == json.dumps(config, indent=4, sort_keys=True)
|
config['keypair']['private'] = 'x' * 45
|
||||||
|
assert output_config == config
|
||||||
|
|
||||||
|
|
||||||
def test_bigchain_run_init_when_db_exists(mock_db_init_with_existing_db):
|
def test_bigchain_run_init_when_db_exists(mock_db_init_with_existing_db):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user