From afcc3dfcd30ed8f7a03598c0ea1ed13015117635 Mon Sep 17 00:00:00 2001 From: Boris Bobrov Date: Thu, 22 Jan 2015 18:31:23 +0300 Subject: [PATCH] Fix 0 version handling in migration_cli manager Change-Id: Ieabcf541bd5f2e6706159efe9d6ac54c7376004c Closes-Bug: 1413277 --- oslo_db/sqlalchemy/migration_cli/manager.py | 2 +- oslo_db/tests/sqlalchemy/test_migrate_cli.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/oslo_db/sqlalchemy/migration_cli/manager.py b/oslo_db/sqlalchemy/migration_cli/manager.py index c8ab30e..bda3c2a 100644 --- a/oslo_db/sqlalchemy/migration_cli/manager.py +++ b/oslo_db/sqlalchemy/migration_cli/manager.py @@ -57,7 +57,7 @@ class MigrationManager(object): last = None for plugin in self._plugins: version = plugin.version() - if version: + if version is not None: last = version return last diff --git a/oslo_db/tests/sqlalchemy/test_migrate_cli.py b/oslo_db/tests/sqlalchemy/test_migrate_cli.py index c1ab53c..6ad693c 100644 --- a/oslo_db/tests/sqlalchemy/test_migrate_cli.py +++ b/oslo_db/tests/sqlalchemy/test_migrate_cli.py @@ -161,6 +161,7 @@ class TestMigrationManager(test_base.BaseTestCase): self.migration_manager = manager.MigrationManager( self.migration_config) self.ext = mock.Mock() + self.ext.obj.version = mock.Mock(return_value=0) self.migration_manager._manager.extensions = [self.ext] super(TestMigrationManager, self).setUp() @@ -180,6 +181,10 @@ class TestMigrationManager(test_base.BaseTestCase): self.migration_manager.version() self.ext.obj.version.assert_called_once_with() + def test_version_return_value(self): + version = self.migration_manager.version() + self.assertEqual(0, version) + def test_revision_message_autogenerate(self): self.migration_manager.revision('test', True) self.ext.obj.revision.assert_called_once_with('test', True)