1
0
mirror of https://github.com/bigchaindb/bigchaindb.git synced 2024-06-16 17:43:21 +02:00

Rename bigchain.py command module to bigchaindb.py

This commit is contained in:
Lavina 2017-03-29 20:05:01 +05:30 committed by Sylvain Bellemare
parent 87eb070ed6
commit e7b0b227f1
7 changed files with 43 additions and 43 deletions

View File

@ -6,10 +6,10 @@ Command Line Interface
:special-members: __init__
:mod:`bigchaindb.commands.bigchain`
:mod:`bigchaindb.commands.bigchaindb`
-----------------------------------
.. automodule:: bigchaindb.commands.bigchain
.. automodule:: bigchaindb.commands.bigchaindb
:mod:`bigchaindb.commands.utils`

View File

@ -117,7 +117,7 @@ setup(
entry_points={
'console_scripts': [
'bigchaindb=bigchaindb.commands.bigchain:main'
'bigchaindb=bigchaindb.commands.bigchaindb:main'
],
},
install_requires=install_requires,

View File

@ -5,8 +5,8 @@ import pytest
@pytest.fixture
def mock_run_configure(monkeypatch):
from bigchaindb.commands import bigchain
monkeypatch.setattr(bigchain, 'run_configure', lambda *args, **kwargs: None)
from bigchaindb.commands import bigchaindb
monkeypatch.setattr(bigchaindb, 'run_configure', lambda *args, **kwargs: None)
@pytest.fixture
@ -17,8 +17,8 @@ def mock_write_config(monkeypatch):
@pytest.fixture
def mock_db_init_with_existing_db(monkeypatch):
from bigchaindb.commands import bigchain
monkeypatch.setattr(bigchain, '_run_init', lambda: None)
from bigchaindb.commands import bigchaindb
monkeypatch.setattr(bigchaindb, '_run_init', lambda: None)
@pytest.fixture

View File

@ -11,7 +11,7 @@ def test_bigchain_run_start_with_rethinkdb(mock_start_rethinkdb,
mock_processes_start,
mock_db_init_with_existing_db,
mocked_setup_logging):
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
args = Namespace(start_rethinkdb=True, allow_temp_keypair=False, config=None, yes=True)
run_start(args)
@ -39,7 +39,7 @@ def test_start_rethinkdb_exits_when_cannot_start(mock_popen):
@patch('rethinkdb.ast.Table.reconfigure')
def test_set_shards(mock_reconfigure, monkeypatch, b):
from bigchaindb.commands.bigchain import run_set_shards
from bigchaindb.commands.bigchaindb import run_set_shards
# this will mock the call to retrieve the database config
# we will set it to return one replica
@ -62,7 +62,7 @@ def test_set_shards(mock_reconfigure, monkeypatch, b):
def test_set_shards_raises_exception(monkeypatch, b):
from bigchaindb.commands.bigchain import run_set_shards
from bigchaindb.commands.bigchaindb import run_set_shards
# test that we are correctly catching the exception
def mock_raise(*args, **kwargs):
@ -82,7 +82,7 @@ def test_set_shards_raises_exception(monkeypatch, b):
@patch('rethinkdb.ast.Table.reconfigure')
def test_set_replicas(mock_reconfigure, monkeypatch, b):
from bigchaindb.commands.bigchain import run_set_replicas
from bigchaindb.commands.bigchaindb import run_set_replicas
# this will mock the call to retrieve the database config
# we will set it to return two shards
@ -105,7 +105,7 @@ def test_set_replicas(mock_reconfigure, monkeypatch, b):
def test_set_replicas_raises_exception(monkeypatch, b):
from bigchaindb.commands.bigchain import run_set_replicas
from bigchaindb.commands.bigchaindb import run_set_replicas
# test that we are correctly catching the exception
def mock_raise(*args, **kwargs):

View File

@ -8,7 +8,7 @@ import pytest
def test_make_sure_we_dont_remove_any_command():
# thanks to: http://stackoverflow.com/a/18161115/597097
from bigchaindb.commands.bigchain import create_parser
from bigchaindb.commands.bigchaindb import create_parser
parser = create_parser()
@ -27,7 +27,7 @@ def test_make_sure_we_dont_remove_any_command():
@patch('bigchaindb.commands.utils.start')
def test_main_entrypoint(mock_start):
from bigchaindb.commands.bigchain import main
from bigchaindb.commands.bigchaindb import main
main()
assert mock_start.called
@ -37,7 +37,7 @@ def test_bigchain_run_start(mock_run_configure,
mock_processes_start,
mock_db_init_with_existing_db,
mocked_setup_logging):
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
args = Namespace(start_rethinkdb=False, allow_temp_keypair=False, config=None, yes=True)
run_start(args)
mocked_setup_logging.assert_called_once_with(user_log_config={})
@ -48,7 +48,7 @@ def test_bigchain_run_start_assume_yes_create_default_config(
monkeypatch, mock_processes_start, mock_generate_key_pair,
mock_db_init_with_existing_db, mocked_setup_logging):
import bigchaindb
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
from bigchaindb import config_utils
value = {}
@ -76,7 +76,7 @@ def test_bigchain_run_start_assume_yes_create_default_config(
@pytest.mark.usefixtures('ignore_local_config_file')
def test_bigchain_show_config(capsys):
from bigchaindb import config
from bigchaindb.commands.bigchain import run_show_config
from bigchaindb.commands.bigchaindb import run_show_config
args = Namespace(config=None)
_, _ = capsys.readouterr()
@ -89,7 +89,7 @@ def test_bigchain_show_config(capsys):
def test_bigchain_export_my_pubkey_when_pubkey_set(capsys, monkeypatch):
from bigchaindb import config
from bigchaindb.commands.bigchain import run_export_my_pubkey
from bigchaindb.commands.bigchaindb import run_export_my_pubkey
args = Namespace(config='dummy')
# so in run_export_my_pubkey(args) below,
@ -108,7 +108,7 @@ def test_bigchain_export_my_pubkey_when_pubkey_set(capsys, monkeypatch):
def test_bigchain_export_my_pubkey_when_pubkey_not_set(monkeypatch):
from bigchaindb import config
from bigchaindb.commands.bigchain import run_export_my_pubkey
from bigchaindb.commands.bigchaindb import run_export_my_pubkey
args = Namespace(config='dummy')
monkeypatch.setitem(config['keypair'], 'public', None)
@ -125,14 +125,14 @@ def test_bigchain_export_my_pubkey_when_pubkey_not_set(monkeypatch):
def test_bigchain_run_init_when_db_exists(mock_db_init_with_existing_db):
from bigchaindb.commands.bigchain import run_init
from bigchaindb.commands.bigchaindb import run_init
args = Namespace(config=None)
run_init(args)
@patch('bigchaindb.backend.schema.drop_database')
def test_drop_db_when_assumed_yes(mock_db_drop):
from bigchaindb.commands.bigchain import run_drop
from bigchaindb.commands.bigchaindb import run_drop
args = Namespace(config=None, yes=True)
run_drop(args)
@ -141,9 +141,9 @@ def test_drop_db_when_assumed_yes(mock_db_drop):
@patch('bigchaindb.backend.schema.drop_database')
def test_drop_db_when_interactive_yes(mock_db_drop, monkeypatch):
from bigchaindb.commands.bigchain import run_drop
from bigchaindb.commands.bigchaindb import run_drop
args = Namespace(config=None, yes=False)
monkeypatch.setattr('bigchaindb.commands.bigchain.input_on_stderr', lambda x: 'y')
monkeypatch.setattr('bigchaindb.commands.bigchaindb.input_on_stderr', lambda x: 'y')
run_drop(args)
assert mock_db_drop.called
@ -151,16 +151,16 @@ def test_drop_db_when_interactive_yes(mock_db_drop, monkeypatch):
@patch('bigchaindb.backend.schema.drop_database')
def test_drop_db_does_not_drop_when_interactive_no(mock_db_drop, monkeypatch):
from bigchaindb.commands.bigchain import run_drop
from bigchaindb.commands.bigchaindb import run_drop
args = Namespace(config=None, yes=False)
monkeypatch.setattr('bigchaindb.commands.bigchain.input_on_stderr', lambda x: 'n')
monkeypatch.setattr('bigchaindb.commands.bigchaindb.input_on_stderr', lambda x: 'n')
run_drop(args)
assert not mock_db_drop.called
def test_run_configure_when_config_exists_and_skipping(monkeypatch):
from bigchaindb.commands.bigchain import run_configure
from bigchaindb.commands.bigchaindb import run_configure
monkeypatch.setattr('os.path.exists', lambda path: True)
args = Namespace(config='foo', yes=True)
return_value = run_configure(args, skip_if_exists=True)
@ -174,7 +174,7 @@ def test_run_configure_when_config_does_not_exist(monkeypatch,
mock_write_config,
mock_generate_key_pair,
mock_bigchaindb_backup_config):
from bigchaindb.commands.bigchain import run_configure
from bigchaindb.commands.bigchaindb import run_configure
monkeypatch.setattr('os.path.exists', lambda path: False)
monkeypatch.setattr('builtins.input', lambda: '\n')
args = Namespace(config='foo', backend='rethinkdb', yes=True)
@ -191,7 +191,7 @@ def test_run_configure_when_config_does_exist(monkeypatch,
def mock_write_config(newconfig, filename=None):
value['return'] = newconfig
from bigchaindb.commands.bigchain import run_configure
from bigchaindb.commands.bigchaindb import run_configure
monkeypatch.setattr('os.path.exists', lambda path: True)
monkeypatch.setattr('builtins.input', lambda: '\n')
monkeypatch.setattr('bigchaindb.config_utils.write_config', mock_write_config)
@ -207,7 +207,7 @@ def test_run_configure_when_config_does_exist(monkeypatch,
))
def test_run_configure_with_backend(backend, monkeypatch, mock_write_config):
import bigchaindb
from bigchaindb.commands.bigchain import run_configure
from bigchaindb.commands.bigchaindb import run_configure
value = {}
@ -238,7 +238,7 @@ def test_allow_temp_keypair_generates_one_on_the_fly(
mock_gen_keypair, mock_processes_start,
mock_db_init_with_existing_db, mocked_setup_logging):
import bigchaindb
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
bigchaindb.config['keypair'] = {'private': None, 'public': None}
@ -258,7 +258,7 @@ def test_allow_temp_keypair_doesnt_override_if_keypair_found(mock_gen_keypair,
mock_db_init_with_existing_db,
mocked_setup_logging):
import bigchaindb
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
# Preconditions for the test
original_private_key = bigchaindb.config['keypair']['private']
@ -279,7 +279,7 @@ def test_run_start_when_db_already_exists(mocker,
monkeypatch,
run_start_args,
mocked_setup_logging):
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
from bigchaindb.common.exceptions import DatabaseAlreadyExists
mocked_start = mocker.patch('bigchaindb.processes.start')
@ -287,7 +287,7 @@ def test_run_start_when_db_already_exists(mocker,
raise DatabaseAlreadyExists()
monkeypatch.setattr(
'bigchaindb.commands.bigchain._run_init', mock_run_init)
'bigchaindb.commands.bigchaindb._run_init', mock_run_init)
run_start(run_start_args)
mocked_setup_logging.assert_called_once_with(user_log_config={})
assert mocked_start.called
@ -297,7 +297,7 @@ def test_run_start_when_keypair_not_found(mocker,
monkeypatch,
run_start_args,
mocked_setup_logging):
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
from bigchaindb.commands.messages import CANNOT_START_KEYPAIR_NOT_FOUND
from bigchaindb.common.exceptions import KeypairNotFoundException
mocked_start = mocker.patch('bigchaindb.processes.start')
@ -306,7 +306,7 @@ def test_run_start_when_keypair_not_found(mocker,
raise KeypairNotFoundException()
monkeypatch.setattr(
'bigchaindb.commands.bigchain._run_init', mock_run_init)
'bigchaindb.commands.bigchaindb._run_init', mock_run_init)
with pytest.raises(SystemExit) as exc:
run_start(run_start_args)
@ -321,7 +321,7 @@ def test_run_start_when_start_rethinkdb_fails(mocker,
monkeypatch,
run_start_args,
mocked_setup_logging):
from bigchaindb.commands.bigchain import run_start
from bigchaindb.commands.bigchaindb import run_start
from bigchaindb.commands.messages import RETHINKDB_STARTUP_ERROR
from bigchaindb.common.exceptions import StartupError
run_start_args.start_rethinkdb = True
@ -348,7 +348,7 @@ def test_run_start_when_start_rethinkdb_fails(mocker,
@patch('bigchaindb.commands.utils.start')
def test_calling_main(start_mock, base_parser_mock, parse_args_mock,
monkeypatch):
from bigchaindb.commands.bigchain import main
from bigchaindb.commands.bigchaindb import main
argparser_mock = Mock()
parser = Mock()
@ -404,9 +404,9 @@ def test_calling_main(start_mock, base_parser_mock, parse_args_mock,
@pytest.mark.usefixtures('ignore_local_config_file')
@patch('bigchaindb.commands.bigchain.add_replicas')
@patch('bigchaindb.commands.bigchaindb.add_replicas')
def test_run_add_replicas(mock_add_replicas):
from bigchaindb.commands.bigchain import run_add_replicas
from bigchaindb.commands.bigchaindb import run_add_replicas
from bigchaindb.backend.exceptions import OperationError
args = Namespace(config=None, replicas=['localhost:27017'])
@ -435,9 +435,9 @@ def test_run_add_replicas(mock_add_replicas):
@pytest.mark.usefixtures('ignore_local_config_file')
@patch('bigchaindb.commands.bigchain.remove_replicas')
@patch('bigchaindb.commands.bigchaindb.remove_replicas')
def test_run_remove_replicas(mock_remove_replicas):
from bigchaindb.commands.bigchain import run_remove_replicas
from bigchaindb.commands.bigchaindb import run_remove_replicas
from bigchaindb.backend.exceptions import OperationError
args = Namespace(config=None, replicas=['localhost:27017'])

View File

@ -54,7 +54,7 @@ def test_configure_bigchaindb_logging(log_level):
def test_start_raises_if_command_not_implemented():
from bigchaindb.commands import utils
from bigchaindb.commands.bigchain import create_parser
from bigchaindb.commands.bigchaindb import create_parser
parser = create_parser()
@ -66,7 +66,7 @@ def test_start_raises_if_command_not_implemented():
def test_start_raises_if_no_arguments_given():
from bigchaindb.commands import utils
from bigchaindb.commands.bigchain import create_parser
from bigchaindb.commands.bigchaindb import create_parser
parser = create_parser()