diff --git a/bigchaindb/commands/bigchaindb.py b/bigchaindb/commands/bigchaindb.py index b575ca7c..5fabc769 100644 --- a/bigchaindb/commands/bigchaindb.py +++ b/bigchaindb/commands/bigchaindb.py @@ -212,7 +212,12 @@ def run_upsert_validator_show(args, bigchain): node_id = new_validator['node_id'] status = election.get_status(bigchain) - logger.info(f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}') + response = f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}' + + logger.info(response) + + # TODO: Remove this once tests/commands/test_utils.test_configure_bigchaindb_logging.py is fixed + return response def _run_init(): diff --git a/tests/commands/test_utils.py b/tests/commands/test_utils.py index 6b00cd30..76731b48 100644 --- a/tests/commands/test_utils.py +++ b/tests/commands/test_utils.py @@ -72,6 +72,11 @@ def test_configure_bigchaindb_configures_bigchaindb(): logging.CRITICAL) ))) def test_configure_bigchaindb_logging(log_level): + # TODO: See following comment: + # This is a dirty test. If a test *preceding* this test makes use of the logger, and then another test *after* this + # test also makes use of the logger, somehow we get logger.disabled == True, and the later test fails. We need to + # engineer this somehow to leave the test env in the same state as it finds it. + from bigchaindb.commands.utils import configure_bigchaindb @configure_bigchaindb diff --git a/tests/upsert_validator/test_validator_election.py b/tests/upsert_validator/test_validator_election.py index 598cb753..5d33912a 100644 --- a/tests/upsert_validator/test_validator_election.py +++ b/tests/upsert_validator/test_validator_election.py @@ -1,7 +1,6 @@ # 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 -import logging from argparse import Namespace import pytest @@ -144,8 +143,7 @@ def test_get_status_inconclusive(b, inconclusive_election, new_validator): assert resp == status -@pytest.mark.dev -def test_upsert_validator_show(caplog, ongoing_election, b, priv_validator_path, user_sk, monkeypatch): +def test_upsert_validator_show(caplog, ongoing_election, b): from bigchaindb.commands.bigchaindb import run_upsert_validator_show election_id = ongoing_election.id @@ -157,7 +155,13 @@ def test_upsert_validator_show(caplog, ongoing_election, b, priv_validator_path, show_args = Namespace(action='show', election_id=election_id) - with caplog.at_level(logging.INFO): - run_upsert_validator_show(show_args, b) - msg = caplog.records.pop().msg - assert msg == f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}' + # TODO: Turn this back on once tests/commands/test_utils.test_configure_bigchaindb_logging.py is fixed + # with caplog.at_level(logging.INFO): + # run_upsert_validator_show(show_args, b) + # msg = caplog.records.pop().msg + # assert msg == f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}' + + # TODO: Remove everything after this once tests/commands/test_utils.test_configure_bigchaindb_logging.py is fixed + msg = run_upsert_validator_show(show_args, b) + + assert msg == f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}'