Improve tests for class initialization

This commit is contained in:
vrde 2016-12-07 11:50:47 +01:00 committed by Sylvain Bellemare
parent d6703e10f3
commit 3c3c1ce880

View File

@ -31,8 +31,12 @@ def config(request, monkeypatch):
def test_bigchain_class_default_initialization(config):
from bigchaindb.core import Bigchain
from bigchaindb.consensus import BaseConsensusRules
from bigchaindb.backend.connection import Connection
bigchain = Bigchain()
assert bigchain.connection
assert isinstance(bigchain.connection, Connection)
assert bigchain.connection.host == config['database']['host']
assert bigchain.connection.port == config['database']['port']
assert bigchain.connection.dbname == config['database']['name']
assert bigchain.me == config['keypair']['public']
assert bigchain.me_private == config['keypair']['private']
assert bigchain.nodes_except_me == config['keyring']
@ -41,16 +45,25 @@ def test_bigchain_class_default_initialization(config):
def test_bigchain_class_initialization_with_parameters(config):
from bigchaindb.core import Bigchain
from bigchaindb.backend.connection import Connection
from bigchaindb.backend import connect
from bigchaindb.consensus import BaseConsensusRules
init_kwargs = {
'public_key': 'white',
'private_key': 'black',
'keyring': ['key_one', 'key_two'],
}
connection = Connection()
init_db_kwargs = {
'backend': 'rethinkdb',
'host': 'this_is_the_db_host',
'port': 12345,
'name': 'this_is_the_db_name',
}
connection = connect(**init_db_kwargs)
bigchain = Bigchain(connection=connection, **init_kwargs)
assert bigchain.connection == connection
assert bigchain.connection.host == init_db_kwargs['host']
assert bigchain.connection.port == init_db_kwargs['port']
assert bigchain.connection.dbname == init_db_kwargs['name']
assert bigchain.me == init_kwargs['public_key']
assert bigchain.me_private == init_kwargs['private_key']
assert bigchain.nodes_except_me == init_kwargs['keyring']