Fix exception name

This commit is contained in:
Sylvain Bellemare 2016-02-14 17:18:41 +01:00
parent 0eb3748db5
commit d3a0b9515c
2 changed files with 41 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import argparse
import bigchaindb
import bigchaindb.config_utils
from bigchaindb import db
from bigchaindb.exceptions import DatabaseAlreadyExists
from bigchaindb.commands.utils import base_parser, start
from bigchaindb.processes import Processes
from bigchaindb.crypto import generate_key_pair
@ -75,7 +76,7 @@ def run_start(args):
bigchaindb.config_utils.file_config(args.config)
try:
db.init()
except db.DatabaseAlreadyExistsException:
except DatabaseAlreadyExists:
pass
p = Processes()
logger.info('Start bigchaindb main process')

39
tests/test_commands.py Normal file
View File

@ -0,0 +1,39 @@
from argparse import Namespace
import pytest
@pytest.fixture
def mock_run_configure(monkeypatch):
from bigchaindb.commands import bigchain
monkeypatch.setattr(bigchain, 'run_configure', lambda *args, **kwargs: None)
@pytest.fixture
def mock_file_config(monkeypatch):
from bigchaindb import config_utils
monkeypatch.setattr(config_utils, 'file_config', lambda *args: None)
@pytest.fixture
def mock_db_init_with_existing_db(monkeypatch):
from bigchaindb import db
from bigchaindb.exceptions import DatabaseAlreadyExists
def mockreturn():
raise DatabaseAlreadyExists
monkeypatch.setattr(db, 'init', mockreturn)
@pytest.fixture
def mock_processes_start(monkeypatch):
from bigchaindb.processes import Processes
monkeypatch.setattr(Processes, 'start', lambda *args: None)
def test_bigchain_run_start(mock_run_configure, mock_file_config,
mock_processes_start, mock_db_init_with_existing_db):
from bigchaindb.commands.bigchain import run_start
args = Namespace(config=None, yes=True)
run_start(args)