mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00

* Problem: RethinkDB, change feed, old mongo, admin interface are not supported any longer. Solution: Remove unsupported functionality. Bring the MongoDB backend implementation completely to the localmongodb package. Fix the test setup. * Problem: Nothing depends on multipipes any longer. Solution: Remove multipipes from setup.py. * Problem: The how-to-run-tests doc uses --database-backend. Solution: Do not include the --database-backend option into the documented pytest usage. * Problem: The backends docs are outdated. Solution: Document MongoDB as the default and only backend for BigchainDB. * Problem: The inputs fixtures uses old blocks API. Solution: Change the inputs fixtures to use the new blocks API. * Problem: rethinkdb package is not used anymore. Solution: Remove the rethinkdb dependency from setup.py. * Problem: The abci-marked tests use outdated Mongo conn. Solution: Replace MongoDBConnection with LocalMongoDBConnection for them.
76 lines
1.9 KiB
Python
76 lines
1.9 KiB
Python
from functools import singledispatch
|
|
from types import ModuleType
|
|
|
|
import pytest
|
|
|
|
|
|
pytestmark = pytest.mark.tendermint
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_module():
|
|
return ModuleType('mock_module')
|
|
|
|
|
|
def test_module_dispatch_registers(mock_module):
|
|
from bigchaindb.backend.utils import module_dispatch_registrar
|
|
|
|
@singledispatch
|
|
def dispatcher(t):
|
|
pass
|
|
mock_module.dispatched = dispatcher
|
|
mock_dispatch = module_dispatch_registrar(mock_module)
|
|
|
|
@mock_dispatch(str)
|
|
def dispatched(t):
|
|
pass
|
|
|
|
assert mock_module.dispatched.registry[str] == dispatched
|
|
|
|
|
|
def test_module_dispatch_dispatches(mock_module):
|
|
from bigchaindb.backend.utils import module_dispatch_registrar
|
|
|
|
@singledispatch
|
|
def dispatcher(t):
|
|
return False
|
|
mock_module.dispatched = dispatcher
|
|
mock_dispatch = module_dispatch_registrar(mock_module)
|
|
|
|
@mock_dispatch(str)
|
|
def dispatched(t):
|
|
return True
|
|
|
|
assert mock_module.dispatched(1) is False # Goes to dispatcher()
|
|
assert mock_module.dispatched('1') is True # Goes to dispatched()
|
|
|
|
|
|
def test_module_dispatch_errors_on_missing_func(mock_module):
|
|
from bigchaindb.backend.utils import (
|
|
module_dispatch_registrar,
|
|
ModuleDispatchRegistrationError,
|
|
)
|
|
mock_dispatch = module_dispatch_registrar(mock_module)
|
|
|
|
with pytest.raises(ModuleDispatchRegistrationError):
|
|
@mock_dispatch(str)
|
|
def dispatched():
|
|
pass
|
|
|
|
|
|
def test_module_dispatch_errors_on_non_dispatchable_func(mock_module):
|
|
from bigchaindb.backend.utils import (
|
|
module_dispatch_registrar,
|
|
ModuleDispatchRegistrationError,
|
|
)
|
|
|
|
def dispatcher():
|
|
pass
|
|
mock_module.dispatched = dispatcher
|
|
mock_dispatch = module_dispatch_registrar(mock_module)
|
|
|
|
with pytest.raises(ModuleDispatchRegistrationError):
|
|
@mock_dispatch(str)
|
|
def dispatched():
|
|
pass
|