mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Retrieve default backend from env if set.
Fixed tests.
This commit is contained in:
parent
555745abbf
commit
fafdac2523
@ -20,6 +20,11 @@ _database_mongodb = {
|
|||||||
'replicaset': os.environ.get('BIGCHAINDB_DATABASE_REPLICASET', 'bigchain-rs'),
|
'replicaset': os.environ.get('BIGCHAINDB_DATABASE_REPLICASET', 'bigchain-rs'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_database_map = {
|
||||||
|
'mongodb': _database_mongodb,
|
||||||
|
'rethinkdb': _database_rethinkdb
|
||||||
|
}
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
'server': {
|
'server': {
|
||||||
# Note: this section supports all the Gunicorn settings:
|
# Note: this section supports all the Gunicorn settings:
|
||||||
@ -28,7 +33,9 @@ config = {
|
|||||||
'workers': None, # if none, the value will be cpu_count * 2 + 1
|
'workers': None, # if none, the value will be cpu_count * 2 + 1
|
||||||
'threads': None, # if none, the value will be cpu_count * 2 + 1
|
'threads': None, # if none, the value will be cpu_count * 2 + 1
|
||||||
},
|
},
|
||||||
'database': _database_rethinkdb,
|
'database': _database_map[
|
||||||
|
os.environ.get('BIGCHAINDB_DATABASE_BACKEND', 'rethinkdb')
|
||||||
|
],
|
||||||
'keypair': {
|
'keypair': {
|
||||||
'public': None,
|
'public': None,
|
||||||
'private': None,
|
'private': None,
|
||||||
|
@ -131,6 +131,27 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
|||||||
from bigchaindb import config_utils
|
from bigchaindb import config_utils
|
||||||
config_utils.autoconfigure()
|
config_utils.autoconfigure()
|
||||||
|
|
||||||
|
backend = request.config.getoption('--database-backend')
|
||||||
|
database_rethinkdb = {
|
||||||
|
'backend': 'rethinkdb',
|
||||||
|
'host': 'test-host',
|
||||||
|
'port': 4242,
|
||||||
|
'name': 'test-dbname',
|
||||||
|
}
|
||||||
|
database_mongodb = {
|
||||||
|
'backend': 'mongodb',
|
||||||
|
'host': 'test-host',
|
||||||
|
'port': 4242,
|
||||||
|
'name': 'test-dbname',
|
||||||
|
'replicaset': 'bigchain-rs',
|
||||||
|
}
|
||||||
|
|
||||||
|
database = {}
|
||||||
|
if backend == 'mongodb':
|
||||||
|
database = database_mongodb
|
||||||
|
elif backend == 'rethinkdb':
|
||||||
|
database = database_rethinkdb
|
||||||
|
|
||||||
assert bigchaindb.config == {
|
assert bigchaindb.config == {
|
||||||
'CONFIGURED': True,
|
'CONFIGURED': True,
|
||||||
'server': {
|
'server': {
|
||||||
@ -138,12 +159,7 @@ def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
|||||||
'workers': None,
|
'workers': None,
|
||||||
'threads': None,
|
'threads': None,
|
||||||
},
|
},
|
||||||
'database': {
|
'database': database,
|
||||||
'backend': request.config.getoption('--database-backend'),
|
|
||||||
'host': 'test-host',
|
|
||||||
'port': 4242,
|
|
||||||
'name': 'test-dbname',
|
|
||||||
},
|
|
||||||
'keypair': {
|
'keypair': {
|
||||||
'public': None,
|
'public': None,
|
||||||
'private': None,
|
'private': None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user