summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOleksii Chuprykov <ochuprykov@mirantis.com>2014-09-04 15:52:04 +0300
committerOleksii Chuprykov <ochuprykov@mirantis.com>2014-09-05 15:32:50 +0300
commit49ae6c0446ec16993d6897543ee66f7ee6f22244 (patch)
treedde568d56bde60e6d466b421ac6aed135f27be79 /tests
parent9234bbbc8477694a2c3ccab86d10955dfeb9e54c (diff)
downloadoslo-db-49ae6c0446ec16993d6897543ee66f7ee6f22244.tar.gz
Renaming in WalkVersionsMixin
Rename _walk_versions(), _migrate_up(), _migrate_down() and mark them deprecated as they will be removed in few releases. These functions will be the part of public API as this class will be used for migrations in other OpenStack projects, so there is no need to make them 'private'. Change-Id: Ic9358445e60a0dd43a5900e8bda7b12f2bebf679
Diffstat (limited to 'tests')
-rw-r--r--tests/sqlalchemy/test_migrations.py58
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/sqlalchemy/test_migrations.py b/tests/sqlalchemy/test_migrations.py
index bb50e4e..49bacaa 100644
--- a/tests/sqlalchemy/test_migrations.py
+++ b/tests/sqlalchemy/test_migrations.py
@@ -39,7 +39,7 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
def test_migrate_up(self):
self.migration_api.db_version.return_value = 141
- self._migrate_up(141)
+ self.migrate_up(141)
self.migration_api.upgrade.assert_called_with(
self.engine, self.REPOSITORY, 141)
@@ -57,7 +57,7 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
'upgrade',
side_effect=exc.DbMigrationError):
log = self.useFixture(fixtures.FakeLogger())
- self.assertRaises(exc.DbMigrationError, self._migrate_up, version)
+ self.assertRaises(exc.DbMigrationError, self.migrate_up, version)
self.assertEqual(expected_output, log.output)
def test_migrate_up_with_data(self):
@@ -67,7 +67,7 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
self._pre_upgrade_141.return_value = test_value
self._check_141 = mock.MagicMock()
- self._migrate_up(141, True)
+ self.migrate_up(141, True)
self._pre_upgrade_141.assert_called_with(self.engine)
self._check_141.assert_called_with(self.engine, test_value)
@@ -75,7 +75,7 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
def test_migrate_down(self):
self.migration_api.db_version.return_value = 42
- self.assertTrue(self._migrate_down(42))
+ self.assertTrue(self.migrate_down(42))
self.migration_api.db_version.assert_called_with(
self.engine, self.REPOSITORY)
@@ -83,23 +83,23 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
with mock.patch.object(self.migration_api,
'downgrade',
side_effect=NotImplementedError):
- self.assertFalse(self._migrate_down(self.engine, 42))
+ self.assertFalse(self.migrate_down(self.engine, 42))
def test_migrate_down_with_data(self):
self._post_downgrade_043 = mock.MagicMock()
self.migration_api.db_version.return_value = 42
- self._migrate_down(42, True)
+ self.migrate_down(42, True)
self._post_downgrade_043.assert_called_with(self.engine)
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_up')
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_down')
- def test_walk_versions_all_default(self, _migrate_up, _migrate_down):
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_up')
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_down')
+ def test_walk_versions_all_default(self, migrate_up, migrate_down):
self.REPOSITORY.latest = 20
self.migration_api.db_version.return_value = self.INIT_VERSION
- self._walk_versions()
+ self.walk_versions()
self.migration_api.version_control.assert_called_with(
self.engine, self.REPOSITORY, self.INIT_VERSION)
@@ -109,18 +109,18 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
versions = range(self.INIT_VERSION + 1, self.REPOSITORY.latest + 1)
upgraded = [mock.call(v, with_data=True)
for v in versions]
- self.assertEqual(self._migrate_up.call_args_list, upgraded)
+ self.assertEqual(self.migrate_up.call_args_list, upgraded)
downgraded = [mock.call(v - 1) for v in reversed(versions)]
- self.assertEqual(self._migrate_down.call_args_list, downgraded)
+ self.assertEqual(self.migrate_down.call_args_list, downgraded)
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_up')
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_down')
- def test_walk_versions_all_true(self, _migrate_up, _migrate_down):
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_up')
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_down')
+ def test_walk_versions_all_true(self, migrate_up, migrate_down):
self.REPOSITORY.latest = 20
self.migration_api.db_version.return_value = self.INIT_VERSION
- self._walk_versions(snake_walk=True, downgrade=True)
+ self.walk_versions(snake_walk=True, downgrade=True)
versions = range(self.INIT_VERSION + 1, self.REPOSITORY.latest + 1)
upgraded = []
@@ -128,7 +128,7 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
upgraded.append(mock.call(v, with_data=True))
upgraded.append(mock.call(v))
upgraded.extend([mock.call(v) for v in reversed(versions)])
- self.assertEqual(upgraded, self._migrate_up.call_args_list)
+ self.assertEqual(upgraded, self.migrate_up.call_args_list)
downgraded_1 = [mock.call(v - 1, with_data=True) for v in versions]
downgraded_2 = []
@@ -136,15 +136,15 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
downgraded_2.append(mock.call(v - 1))
downgraded_2.append(mock.call(v - 1))
downgraded = downgraded_1 + downgraded_2
- self.assertEqual(self._migrate_down.call_args_list, downgraded)
+ self.assertEqual(self.migrate_down.call_args_list, downgraded)
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_up')
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_down')
- def test_walk_versions_true_false(self, _migrate_up, _migrate_down):
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_up')
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_down')
+ def test_walk_versions_true_false(self, migrate_up, migrate_down):
self.REPOSITORY.latest = 20
self.migration_api.db_version.return_value = self.INIT_VERSION
- self._walk_versions(snake_walk=True, downgrade=False)
+ self.walk_versions(snake_walk=True, downgrade=False)
versions = range(self.INIT_VERSION + 1, self.REPOSITORY.latest + 1)
@@ -152,23 +152,23 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
for v in versions:
upgraded.append(mock.call(v, with_data=True))
upgraded.append(mock.call(v))
- self.assertEqual(upgraded, self._migrate_up.call_args_list)
+ self.assertEqual(upgraded, self.migrate_up.call_args_list)
downgraded = [mock.call(v - 1, with_data=True) for v in versions]
- self.assertEqual(self._migrate_down.call_args_list, downgraded)
+ self.assertEqual(self.migrate_down.call_args_list, downgraded)
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_up')
- @mock.patch.object(migrate.WalkVersionsMixin, '_migrate_down')
- def test_walk_versions_all_false(self, _migrate_up, _migrate_down):
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_up')
+ @mock.patch.object(migrate.WalkVersionsMixin, 'migrate_down')
+ def test_walk_versions_all_false(self, migrate_up, migrate_down):
self.REPOSITORY.latest = 20
self.migration_api.db_version.return_value = self.INIT_VERSION
- self._walk_versions(snake_walk=False, downgrade=False)
+ self.walk_versions(snake_walk=False, downgrade=False)
versions = range(self.INIT_VERSION + 1, self.REPOSITORY.latest + 1)
upgraded = [mock.call(v, with_data=True) for v in versions]
- self.assertEqual(upgraded, self._migrate_up.call_args_list)
+ self.assertEqual(upgraded, self.migrate_up.call_args_list)
class ModelsMigrationSyncMixin(test.BaseTestCase):