diff --git a/app/commands/commands.py b/app/commands/commands.py index 6901343..86bf26e 100644 --- a/app/commands/commands.py +++ b/app/commands/commands.py @@ -38,7 +38,7 @@ def create_db(): sys.exit(-1) if sqlite_uri: - current_app.logger.info("Created sqlite db: " + sqlite_uri) + print("Created sqlite db: " + sqlite_uri) @bp.cli.command("feed_from_irap") diff --git a/tests/cli_tests.py b/tests/cli_tests.py index 72f9c49..161d90c 100644 --- a/tests/cli_tests.py +++ b/tests/cli_tests.py @@ -1,7 +1,7 @@ import unittest from app import create_app, db, User -from app.commands.commands import feed_from_irap, show_roles, user_add, user_show_all +from app.commands.commands import feed_from_irap, show_roles, user_add, user_show_all, create_db from pdc_config import TestConfig from app.commands import bp as cli_bp @@ -10,7 +10,8 @@ from app.commands import bp as cli_bp class CliBaseTestCase(unittest.TestCase): def setUp(self): - # Get rid of a strange 'ValueError: I/O operation' when app.logger outputs + # Get rid of a strange 'ValueError: I/O operation' when pytest catches app.logger outputs + # Error can also be bypassed with 'pytest -s' option TestConfig.PDC_LOGS_LEVEL = 'ERROR' # Force sqlite in memory db TestConfig.SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:' @@ -24,6 +25,11 @@ class CliBaseTestCase(unittest.TestCase): def tearDown(self): pass + def test_create_db(self): + runner = self.app.test_cli_runner() + result = runner.invoke(create_db) + self.assertTrue('Created sqlite' in result.output) + def test_show_all(self): runner = self.app.test_cli_runner() result = runner.invoke(user_show_all) -- libgit2 0.21.2