2018-08-16 12:31:32 +02:00
|
|
|
# Copyright BigchainDB GmbH and BigchainDB contributors
|
|
|
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
2017-02-28 17:27:42 +01:00
|
|
|
from argparse import Namespace
|
|
|
|
|
2016-12-16 22:17:13 +01:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_run_configure(monkeypatch):
|
2017-03-29 16:35:01 +02:00
|
|
|
from bigchaindb.commands import bigchaindb
|
|
|
|
monkeypatch.setattr(bigchaindb, 'run_configure', lambda *args, **kwargs: None)
|
2016-12-16 22:17:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_write_config(monkeypatch):
|
|
|
|
from bigchaindb import config_utils
|
|
|
|
monkeypatch.setattr(config_utils, 'write_config', lambda *args: None)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_db_init_with_existing_db(monkeypatch):
|
2017-03-29 16:35:01 +02:00
|
|
|
from bigchaindb.commands import bigchaindb
|
|
|
|
monkeypatch.setattr(bigchaindb, '_run_init', lambda: None)
|
2016-12-16 22:17:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_processes_start(monkeypatch):
|
2018-09-10 09:53:18 +02:00
|
|
|
from bigchaindb import start
|
|
|
|
monkeypatch.setattr(start, 'start', lambda *args: None)
|
2016-12-16 22:17:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_generate_key_pair(monkeypatch):
|
|
|
|
monkeypatch.setattr('bigchaindb.common.crypto.generate_key_pair', lambda: ('privkey', 'pubkey'))
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mock_bigchaindb_backup_config(monkeypatch):
|
|
|
|
config = {
|
|
|
|
'database': {'host': 'host', 'port': 12345, 'name': 'adbname'},
|
|
|
|
}
|
|
|
|
monkeypatch.setattr('bigchaindb._config', config)
|
2017-02-28 17:27:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def run_start_args(request):
|
|
|
|
param = getattr(request, 'param', {})
|
|
|
|
return Namespace(
|
|
|
|
config=param.get('config'),
|
2017-11-07 11:11:55 +01:00
|
|
|
skip_initialize_database=param.get('skip_initialize_database', False),
|
2017-02-28 17:27:42 +01:00
|
|
|
)
|
2017-03-13 17:55:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def mocked_setup_logging(mocker):
|
|
|
|
return mocker.patch(
|
2018-09-10 09:53:18 +02:00
|
|
|
'bigchaindb.log.setup_logging',
|
2017-03-13 17:55:11 +01:00
|
|
|
autospec=True,
|
|
|
|
spec_set=True,
|
|
|
|
)
|