diff options
author | Angus Salkeld <angus.salkeld@rackspace.com> | 2014-01-15 09:01:56 +1000 |
---|---|---|
committer | Angus Salkeld <angus.salkeld@rackspace.com> | 2014-01-15 09:01:56 +1000 |
commit | 62e6def2add696f86b0c20af012c5a29afa9acb9 (patch) | |
tree | 11cddd3998d58b7701164e032264a70d8efd4416 /tests | |
parent | 622decb8870ff7b8b45a539e360d033d9f749e2f (diff) | |
download | oslo-db-62e6def2add696f86b0c20af012c5a29afa9acb9.tar.gz |
Add a db check for CHARSET=utf8
This is to prevent confusing migration errors caused by
tables having mixed character sets like latin1.
Change-Id: I19da8d5e2d972c78d0f9fb4325445f538ed35600
Closes-bug: #1261605
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/db/sqlalchemy/test_migration_common.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/db/sqlalchemy/test_migration_common.py b/tests/unit/db/sqlalchemy/test_migration_common.py index 505eb15..b5fa189 100644 --- a/tests/unit/db/sqlalchemy/test_migration_common.py +++ b/tests/unit/db/sqlalchemy/test_migration_common.py @@ -146,3 +146,24 @@ class TestMigrationCommon(base.DbTestCase): mock_downgrade.assert_called_once_with( db_session.get_engine(), self.return_value, self.test_version) + + def test_db_sync_sanity_called(self): + with contextlib.nested( + mock.patch.object(migration, '_find_migrate_repo'), + mock.patch.object(migration, '_db_schema_sanity_check'), + mock.patch.object(versioning_api, 'downgrade') + ) as (mock_find_repo, mock_sanity, mock_downgrade): + + mock_find_repo.return_value = self.return_value + migration.db_sync(self.path, self.test_version) + + mock_sanity.assert_called_once() + + def test_db_sanity_table_not_utf8(self): + with mock.patch.object(migration, 'get_engine') as mock_get_eng: + mock_eng = mock_get_eng.return_value + type(mock_eng).name = mock.PropertyMock(return_value='mysql') + mock_eng.execute.return_value = [['table_A', 'latin1'], + ['table_B', 'latin1']] + + self.assertRaises(ValueError, migration._db_schema_sanity_check) |