From 27b730143886c3699ed0b072ea2304e47bff9c2d Mon Sep 17 00:00:00 2001 From: Andrew Melton Date: Wed, 19 Aug 2015 09:57:46 -0700 Subject: Use correct config key in alembic extension While the value we're looking for is passed into the Extension as 'alembic_repo_path' it is actually stored in the alembic config as 'script_location'. This change fixes the call to the alembic config and retrieves 'script_location' instead. Change-Id: Ia328e8230d33dc063c0d377e04f15f1ccaa4d500 Closes-Bug: #1486655 --- oslo_db/sqlalchemy/migration_cli/ext_alembic.py | 2 +- oslo_db/tests/sqlalchemy/test_migrate_cli.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/oslo_db/sqlalchemy/migration_cli/ext_alembic.py b/oslo_db/sqlalchemy/migration_cli/ext_alembic.py index 825c638..0348a37 100644 --- a/oslo_db/sqlalchemy/migration_cli/ext_alembic.py +++ b/oslo_db/sqlalchemy/migration_cli/ext_alembic.py @@ -95,7 +95,7 @@ class AlembicExtension(ext_base.MigrationExtensionBase): if rev_id in ['base', 'head']: return True script = alembic_script.ScriptDirectory( - self.config.get_main_option('alembic_repo_path')) + self.config.get_main_option('script_location')) try: script.get_revision(rev_id) return True diff --git a/oslo_db/tests/sqlalchemy/test_migrate_cli.py b/oslo_db/tests/sqlalchemy/test_migrate_cli.py index 6bdb09a..72d8b4e 100644 --- a/oslo_db/tests/sqlalchemy/test_migrate_cli.py +++ b/oslo_db/tests/sqlalchemy/test_migrate_cli.py @@ -103,6 +103,8 @@ class TestAlembicExtension(test_base.BaseTestCase): # since alembic_script is mocked and no exception is raised, call # will result in success self.assertIs(True, self.alembic.has_revision('test')) + self.alembic.config.get_main_option.assert_called_once_with( + 'script_location') mocked.ScriptDirectory().get_revision.assert_called_once_with( 'test') self.assertIs(True, self.alembic.has_revision(None)) @@ -116,6 +118,8 @@ class TestAlembicExtension(test_base.BaseTestCase): self.alembic.config.get_main_option = mock.Mock() # exception is raised, the call should be false self.assertIs(False, self.alembic.has_revision('test')) + self.alembic.config.get_main_option.assert_called_once_with( + 'script_location') mocked.ScriptDirectory().get_revision.assert_called_once_with( 'test') -- cgit v1.2.1