summaryrefslogtreecommitdiff
path: root/src/mailman/database/tests/test_migrations.py
diff options
context:
space:
mode:
authorBarry Warsaw2013-09-01 11:15:08 -0400
committerBarry Warsaw2013-09-01 11:15:08 -0400
commitd146f14b3eef9f608c0e03347c135062bade8ced (patch)
tree5a1f2f576dd7d5dcce4d6903df5cc4b6cb754815 /src/mailman/database/tests/test_migrations.py
parent41059ed20ec668baf41cceaf539f8017171e9651 (diff)
downloadmailman-d146f14b3eef9f608c0e03347c135062bade8ced.tar.gz
mailman-d146f14b3eef9f608c0e03347c135062bade8ced.tar.zst
mailman-d146f14b3eef9f608c0e03347c135062bade8ced.zip
Diffstat (limited to 'src/mailman/database/tests/test_migrations.py')
-rw-r--r--src/mailman/database/tests/test_migrations.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py
index 410192605..c264948ae 100644
--- a/src/mailman/database/tests/test_migrations.py
+++ b/src/mailman/database/tests/test_migrations.py
@@ -26,11 +26,14 @@ __all__ = [
'TestMigration20120407UnchangedData',
'TestMigration20121015MigratedData',
'TestMigration20121015Schema',
+ 'TestMigration20130406MigratedData',
+ 'TestMigration20130406Schema',
]
import unittest
+from datetime import datetime
from operator import attrgetter
from pkg_resources import resource_string
from storm.exceptions import DatabaseError
@@ -44,6 +47,7 @@ from mailman.interfaces.mailinglist import IAcceptableAliasSet
from mailman.interfaces.nntp import NewsgroupModeration
from mailman.interfaces.subscriptions import ISubscriptionService
from mailman.model.bans import Ban
+from mailman.model.bounce import BounceContext, BounceEvent
from mailman.testing.helpers import temporary_db
from mailman.testing.layers import ConfigLayer
@@ -426,3 +430,49 @@ class TestMigration20121015MigratedData(MigrationTestBase):
self.assertEqual(bans[0].list_id, 'test.example.com')
self.assertEqual(bans[1].email, 'bart@example.com')
self.assertEqual(bans[1].list_id, None)
+
+
+
+class TestMigration20130406Schema(MigrationTestBase):
+ """Test column migrations."""
+
+ def test_pre_upgrade_column_migrations(self):
+ self._missing_present('bounceevent',
+ ['20130405999999'],
+ ('list_id',),
+ ('list_name',))
+
+ def test_post_upgrade_column_migrations(self):
+ self._missing_present('bounceevent',
+ ['20130405999999',
+ '20130406000000'],
+ ('list_name',),
+ ('list_id',))
+
+
+
+class TestMigration20130406MigratedData(MigrationTestBase):
+ """Test migrated data."""
+
+ def test_migration_bounceevent(self):
+ # Load all migrations to just before the one we're testing.
+ self._database.load_migrations('20130405999999')
+ # Insert a bounce event.
+ self._database.store.execute("""
+ INSERT INTO bounceevent VALUES (
+ 1, 'test@example.com', 'anne@example.com',
+ '2013-04-06 21:12:00', '<abc@example.com>',
+ 1, 0);
+ """)
+ # Update to the current migration we're testing
+ self._database.load_migrations('20130406000000')
+ # The bounce event should exist, but with a list-id instead of a fqdn
+ # list name.
+ events = list(self._database.store.find(BounceEvent))
+ self.assertEqual(len(events), 1)
+ self.assertEqual(events[0].list_id, 'test.example.com')
+ self.assertEqual(events[0].email, 'anne@example.com')
+ self.assertEqual(events[0].timestamp, datetime(2013, 4, 6, 21, 12))
+ self.assertEqual(events[0].message_id, '<abc@example.com>')
+ self.assertEqual(events[0].context, BounceContext[1])
+ self.assertFalse(events[0].processed)