diff options
Diffstat (limited to 'ironic/tests/unit')
-rw-r--r-- | ironic/tests/unit/cmd/test_dbsync.py | 8 | ||||
-rw-r--r-- | ironic/tests/unit/db/test_api.py | 20 |
2 files changed, 25 insertions, 3 deletions
diff --git a/ironic/tests/unit/cmd/test_dbsync.py b/ironic/tests/unit/cmd/test_dbsync.py index 530b576e8..618b8bcd5 100644 --- a/ironic/tests/unit/cmd/test_dbsync.py +++ b/ironic/tests/unit/cmd/test_dbsync.py @@ -42,7 +42,8 @@ class OnlineMigrationTestCase(db_base.DbTestCase): mock_check_versions.return_value = True msg = self.db_cmds.check_obj_versions() self.assertIsNone(msg) - mock_check_versions.assert_called_once_with(ignore_models=()) + mock_check_versions.assert_called_once_with( + permit_initial_version=False) def test_check_obj_versions_bad(self): with mock.patch.object(self.dbapi, 'check_versions', @@ -50,7 +51,8 @@ class OnlineMigrationTestCase(db_base.DbTestCase): mock_check_versions.return_value = False msg = self.db_cmds.check_obj_versions() self.assertIsNotNone(msg) - mock_check_versions.assert_called_once_with(ignore_models=()) + mock_check_versions.assert_called_once_with( + permit_initial_version=False) def test_check_obj_versions_ignore_models(self): with mock.patch.object(self.dbapi, 'check_versions', @@ -59,7 +61,7 @@ class OnlineMigrationTestCase(db_base.DbTestCase): msg = self.db_cmds.check_obj_versions(ignore_missing_tables=True) self.assertIsNone(msg) mock_check_versions.assert_called_once_with( - ignore_models=dbsync.NEW_MODELS) + permit_initial_version=True) @mock.patch.object(dbsync.DBCommand, 'check_obj_versions', autospec=True) def test_check_versions_bad(self, mock_check_versions): diff --git a/ironic/tests/unit/db/test_api.py b/ironic/tests/unit/db/test_api.py index f855e9c91..6142fdfae 100644 --- a/ironic/tests/unit/db/test_api.py +++ b/ironic/tests/unit/db/test_api.py @@ -15,6 +15,7 @@ from unittest import mock from oslo_db.sqlalchemy import utils as db_utils from oslo_utils import uuidutils +import sqlalchemy as sa from testtools import matchers from ironic.common import context @@ -42,6 +43,25 @@ class UpgradingTestCase(base.DbTestCase): self.assertRaises(exception.DatabaseVersionTooOld, self.dbapi.check_versions) + @mock.patch.object(release_mappings, 'get_object_versions', autospec=True) + @mock.patch.object(db_utils, 'column_exists', autospec=True) + def test_check_versions_handles_missing_table( + self, column_exists, mock_release_mappings): + column_exists.side_effect = sa.exc.NoSuchTableError('meow') + mock_release_mappings.return_value = {'Node': {'1.0'}} + self.assertTrue( + self.dbapi.check_versions(permit_initial_version=True)) + self.assertEqual(1, column_exists.call_count) + + @mock.patch.object(release_mappings, 'get_object_versions', autospec=True) + @mock.patch.object(db_utils, 'column_exists', autospec=True) + def test_check_versions_raises_missing_table( + self, column_exists, mock_release_mappings): + column_exists.side_effect = sa.exc.NoSuchTableError('meow') + mock_release_mappings.return_value = {'Node': {'1.0', '1.1'}} + self.assertRaises(sa.exc.NoSuchTableError, self.dbapi.check_versions) + self.assertEqual(1, column_exists.call_count) + def test_check_versions(self): for v in self.object_versions['Node']: node = utils.create_test_node(uuid=uuidutils.generate_uuid(), |