Merge "Fix 0 version handling in migration_cli manager"

This commit is contained in:
Jenkins 2015-01-26 16:39:02 +00:00 committed by Gerrit Code Review
commit 1f6103e4ef
2 changed files with 6 additions and 1 deletions

View File

@ -57,7 +57,7 @@ class MigrationManager(object):
last = None last = None
for plugin in self._plugins: for plugin in self._plugins:
version = plugin.version() version = plugin.version()
if version: if version is not None:
last = version last = version
return last return last

View File

@ -161,6 +161,7 @@ class TestMigrationManager(test_base.BaseTestCase):
self.migration_manager = manager.MigrationManager( self.migration_manager = manager.MigrationManager(
self.migration_config) self.migration_config)
self.ext = mock.Mock() self.ext = mock.Mock()
self.ext.obj.version = mock.Mock(return_value=0)
self.migration_manager._manager.extensions = [self.ext] self.migration_manager._manager.extensions = [self.ext]
super(TestMigrationManager, self).setUp() super(TestMigrationManager, self).setUp()
@ -180,6 +181,10 @@ class TestMigrationManager(test_base.BaseTestCase):
self.migration_manager.version() self.migration_manager.version()
self.ext.obj.version.assert_called_once_with() 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): def test_revision_message_autogenerate(self):
self.migration_manager.revision('test', True) self.migration_manager.revision('test', True)
self.ext.obj.revision.assert_called_once_with('test', True) self.ext.obj.revision.assert_called_once_with('test', True)