Skip to content

Commit

Permalink
Add quiet switch
Browse files Browse the repository at this point in the history
As is, dbmigrator is a bit chatty. I will take advantage of this in
cnx-db/script/ci_test_migrations.sh to make non-CI invocation almost
completely silent, so migration failures stand out.
  • Loading branch information
reedstrm authored and karenc committed Oct 27, 2017
1 parent e13e931 commit 1becb2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dbmigrator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser(description='DB Migrator')

parser.add_argument('--verbose', '-v', action='store_true')
parser.add_argument('--quiet', '-q', action='store_true')

parser.add_argument('--migrations-directory',
action='append',
Expand Down Expand Up @@ -97,6 +98,9 @@ def main(argv=sys.argv[1:]):
if args.get('verbose'):
logger.setLevel(logging.DEBUG)

if args.get('quiet'):
logger.setLevel(logging.ERROR)

logger.debug('args: {}'.format(args))
utils.set_settings(args)

Expand Down
7 changes: 7 additions & 0 deletions dbmigrator/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ def test(self):
logger.info.assert_called_with('Schema migrations initialized.')


class QuietTestCase(BaseTestCase):
def test(self):
self.target(['-q', '--config', testing.test_config_path, 'init'])

logger.setLevel.assert_called_with(logging.ERROR)


class ListTestCase(BaseTestCase):
def test_no_migrations_directory(self):
cmd = ['--db-connection-string', testing.db_connection_string]
Expand Down

0 comments on commit 1becb2b

Please sign in to comment.