mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add more test coverage for commands
This commit is contained in:
parent
9b709b7f98
commit
5f603f52ef
@ -66,6 +66,7 @@ def test_make_sure_we_dont_remove_any_command():
|
||||
# thanks to: http://stackoverflow.com/a/18161115/597097
|
||||
from bigchaindb.commands.bigchain import utils
|
||||
from bigchaindb.commands.bigchain import create_parser
|
||||
|
||||
parser = create_parser()
|
||||
|
||||
with pytest.raises(SystemExit):
|
||||
@ -82,6 +83,32 @@ def test_make_sure_we_dont_remove_any_command():
|
||||
assert parser.parse_args(['load']).command
|
||||
|
||||
|
||||
def test_start_raises_if_command_not_implemented():
|
||||
from bigchaindb.commands.bigchain import utils
|
||||
from bigchaindb.commands.bigchain import create_parser
|
||||
|
||||
parser = create_parser()
|
||||
|
||||
with pytest.raises(NotImplementedError):
|
||||
# Will raise because `scope`, the third parameter,
|
||||
# doesn't contain the function `run_configure`
|
||||
utils.start(parser, ['configure'], {})
|
||||
|
||||
|
||||
@patch('multiprocessing.cpu_count', return_value=42)
|
||||
def test_start_sets_multiprocess_var_based_on_cli_args(mock_cpu_count):
|
||||
def run_load(args):
|
||||
return args
|
||||
|
||||
from bigchaindb.commands.bigchain import utils
|
||||
from bigchaindb.commands.bigchain import create_parser
|
||||
|
||||
parser = create_parser()
|
||||
|
||||
assert utils.start(parser, ['load'], {'run_load': run_load}).multiprocess == 1
|
||||
assert utils.start(parser, ['load', '--multiprocess'], {'run_load': run_load}).multiprocess == 42
|
||||
|
||||
|
||||
@patch('bigchaindb.commands.utils.start')
|
||||
def test_main_entrypoint(mock_start):
|
||||
from bigchaindb.commands.bigchain import main
|
||||
|
Loading…
x
Reference in New Issue
Block a user