mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add test for config_utils.file_config()
This commit is contained in:
parent
726ad9cedc
commit
b08f6ebffd
@ -1,4 +1,5 @@
|
|||||||
import copy
|
import copy
|
||||||
|
from unittest.mock import mock_open, patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -9,6 +10,12 @@ from bigchaindb import exceptions
|
|||||||
ORIGINAL_CONFIG = copy.deepcopy(bigchaindb._config)
|
ORIGINAL_CONFIG = copy.deepcopy(bigchaindb._config)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def ignore_local_config_file(monkeypatch):
|
||||||
|
from bigchaindb.config_utils import file_config
|
||||||
|
monkeypatch.setattr('bigchaindb.config_utils.file_config', file_config)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
def clean_config(monkeypatch):
|
def clean_config(monkeypatch):
|
||||||
monkeypatch.setattr('bigchaindb.config', copy.deepcopy(ORIGINAL_CONFIG))
|
monkeypatch.setattr('bigchaindb.config', copy.deepcopy(ORIGINAL_CONFIG))
|
||||||
@ -205,3 +212,11 @@ def test_update_config(monkeypatch):
|
|||||||
assert bigchaindb.config['database']['host'] == 'test-host'
|
assert bigchaindb.config['database']['host'] == 'test-host'
|
||||||
assert bigchaindb.config['database']['name'] == 'bigchaindb_other'
|
assert bigchaindb.config['database']['name'] == 'bigchaindb_other'
|
||||||
assert bigchaindb.config['database']['port'] == 28016
|
assert bigchaindb.config['database']['port'] == 28016
|
||||||
|
|
||||||
|
|
||||||
|
def test_file_config():
|
||||||
|
from bigchaindb.config_utils import file_config, CONFIG_DEFAULT_PATH
|
||||||
|
with patch('builtins.open', mock_open(read_data='{}')) as m:
|
||||||
|
config = file_config()
|
||||||
|
m.assert_called_once_with(CONFIG_DEFAULT_PATH)
|
||||||
|
assert config == {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user