diff options
| author | Barry Warsaw | 2014-04-14 12:14:13 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2014-04-14 12:14:13 -0400 |
| commit | 403cbf23c07839b60c85c0bc791b6437f05c8a85 (patch) | |
| tree | b36d0ecab20e01f23bcf66ab2b27633aaf3e99c3 /src/mailman/database/tests/test_migrations.py | |
| parent | ff6df86000da8fcb055101c5cede36b27cb0480a (diff) | |
| parent | 3a9725b91ef822122a70170333d71b58e1788a78 (diff) | |
| download | mailman-403cbf23c07839b60c85c0bc791b6437f05c8a85.tar.gz mailman-403cbf23c07839b60c85c0bc791b6437f05c8a85.tar.zst mailman-403cbf23c07839b60c85c0bc791b6437f05c8a85.zip | |
Diffstat (limited to 'src/mailman/database/tests/test_migrations.py')
| -rw-r--r-- | src/mailman/database/tests/test_migrations.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py index d983f9891..9619b80a4 100644 --- a/src/mailman/database/tests/test_migrations.py +++ b/src/mailman/database/tests/test_migrations.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012-2013 by the Free Software Foundation, Inc. +# Copyright (C) 2012-2014 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -36,6 +36,7 @@ import unittest from datetime import datetime from operator import attrgetter from pkg_resources import resource_string +from sqlite3 import OperationalError from storm.exceptions import DatabaseError from zope.component import getUtility @@ -65,6 +66,23 @@ class MigrationTestBase(unittest.TestCase): def tearDown(self): self._database._cleanup() + def _table_missing_present(self, migrations, missing, present): + """The appropriate migrations leave some tables missing and present. + + :param migrations: Sequence of migrations to load. + :param missing: Tables which should be missing. + :param present: Tables which should be present. + """ + for migration in migrations: + self._database.load_migrations(migration) + self._database.store.commit() + for table in missing: + self.assertRaises(OperationalError, + self._database.store.execute, + 'select * from {};'.format(table)) + for table in present: + self._database.store.execute('select * from {};'.format(table)) + def _missing_present(self, table, migrations, missing, present): """The appropriate migrations leave columns missing and present. @@ -450,6 +468,15 @@ class TestMigration20130406Schema(MigrationTestBase): ('list_name',), ('list_id',)) + def test_pre_listarchiver_table(self): + self._table_missing_present(['20130405999999'], ('listarchiver',), ()) + + def test_post_listarchiver_table(self): + self._table_missing_present(['20130405999999', + '20130406000000'], + (), + ('listarchiver',)) + class TestMigration20130406MigratedData(MigrationTestBase): |
