diff options
| author | Barry Warsaw | 2012-07-25 13:39:50 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2012-07-25 13:39:50 -0400 |
| commit | 8dec52e851c4cd8fcdd29702b95fad039fcedf2a (patch) | |
| tree | b1a2075161015f6469a13cf93bfeac70e5366a18 | |
| parent | ce410fe79601009220e850ad07b6931d29918376 (diff) | |
| download | mailman-8dec52e851c4cd8fcdd29702b95fad039fcedf2a.tar.gz mailman-8dec52e851c4cd8fcdd29702b95fad039fcedf2a.tar.zst mailman-8dec52e851c4cd8fcdd29702b95fad039fcedf2a.zip | |
| -rw-r--r-- | src/mailman/database/postgresql.py | 8 | ||||
| -rw-r--r-- | src/mailman/database/sqlite.py | 6 | ||||
| -rw-r--r-- | src/mailman/database/tests/test_migrations.py | 22 | ||||
| -rw-r--r-- | src/mailman/testing/testing.cfg | 6 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py index e7c40407a..1d1abca9e 100644 --- a/src/mailman/database/postgresql.py +++ b/src/mailman/database/postgresql.py @@ -34,7 +34,7 @@ from mailman.database.base import StormBaseDatabase -class _TemporaryDB: +class _TestDB: # For the test suite; bool column values. TRUE = 'True' FALSE = 'False' @@ -86,7 +86,7 @@ class PostgreSQLDatabase(StormBaseDatabase): """.format(model_class.__storm_table__)) @staticmethod - def _make_temporary(): + def _make_testdb(): from mailman.testing.helpers import configuration parts = urlsplit(config.database.url) assert parts.scheme == 'postgres' @@ -98,8 +98,8 @@ class PostgreSQLDatabase(StormBaseDatabase): # after the test. config.db.store.execute('ABORT;') config.db.store.execute('CREATE DATABASE mmtest;') - # Now create a new, temporary database. + # Now create a new, test database. database = PostgreSQLDatabase() with configuration('database', url=url): database.initialize() - return _TemporaryDB(database) + return _TestDB(database) diff --git a/src/mailman/database/sqlite.py b/src/mailman/database/sqlite.py index 54dce0352..cdee8f525 100644 --- a/src/mailman/database/sqlite.py +++ b/src/mailman/database/sqlite.py @@ -35,7 +35,7 @@ from mailman.database.base import StormBaseDatabase -class _TemporaryDB: +class _TestDB: # For the test suite; bool column values. TRUE = 1 FALSE = 0 @@ -76,11 +76,11 @@ class SQLiteDatabase(StormBaseDatabase): os.close(fd) @staticmethod - def _make_temporary(): + def _make_testdb(): from mailman.testing.helpers import configuration tempdir = tempfile.mkdtemp() url = 'sqlite:///' + os.path.join(tempdir, 'mailman.db') database = SQLiteDatabase() with configuration('database', url=url): database.initialize() - return _TemporaryDB(database, tempdir) + return _TestDB(database, tempdir) diff --git a/src/mailman/database/tests/test_migrations.py b/src/mailman/database/tests/test_migrations.py index 9d20e0dae..87f012404 100644 --- a/src/mailman/database/tests/test_migrations.py +++ b/src/mailman/database/tests/test_migrations.py @@ -64,11 +64,11 @@ class MigrationTestBase(unittest.TestCase): def setUp(self): database_class_name = config.database['class'] self._database_class = call_name(database_class_name) - self._temporary = self._database_class._make_temporary() - self._database = self._temporary.database + self._testdb = self._database_class._make_testdb() + self._database = self._testdb.database def tearDown(self): - self._temporary.cleanup() + self._testdb.cleanup() @@ -87,7 +87,7 @@ class TestMigration20120407Schema(MigrationTestBase): self.assertRaises(DatabaseError, self._database.store.execute, 'select {0} from mailinglist;'.format(missing)) - self._temporary.abort() + self._testdb.abort() for present in ('archive', 'archive_private', 'archive_volume_frequency', @@ -122,7 +122,7 @@ class TestMigration20120407Schema(MigrationTestBase): self.assertRaises(DatabaseError, self._database.store.execute, 'select {0} from mailinglist;'.format(missing)) - self._temporary.abort() + self._testdb.abort() @@ -212,7 +212,7 @@ class TestMigration20120407ArchiveData(MigrationTestBase): # ignored. This test sets it to 0 to ensure it's ignored. self._database.store.execute( 'UPDATE mailinglist SET archive = {0}, archive_private = {0} ' - 'WHERE id = 1;'.format(self._temporary.FALSE)) + 'WHERE id = 1;'.format(self._testdb.FALSE)) # Complete the migration self._upgrade() with temporary_db(self._database): @@ -225,8 +225,8 @@ class TestMigration20120407ArchiveData(MigrationTestBase): # ignored. This test sets it to 1 to ensure it's ignored. self._database.store.execute( 'UPDATE mailinglist SET archive = {0}, archive_private = {1} ' - 'WHERE id = 1;'.format(self._temporary.FALSE, - self._temporary.TRUE)) + 'WHERE id = 1;'.format(self._testdb.FALSE, + self._testdb.TRUE)) # Complete the migration self._upgrade() with temporary_db(self._database): @@ -238,7 +238,7 @@ class TestMigration20120407ArchiveData(MigrationTestBase): # private archives. self._database.store.execute( 'UPDATE mailinglist SET archive = {0}, archive_private = {0} ' - 'WHERE id = 1;'.format(self._temporary.TRUE)) + 'WHERE id = 1;'.format(self._testdb.TRUE)) # Complete the migration self._upgrade() with temporary_db(self._database): @@ -250,8 +250,8 @@ class TestMigration20120407ArchiveData(MigrationTestBase): # public archives. self._database.store.execute( 'UPDATE mailinglist SET archive = {1}, archive_private = {0} ' - 'WHERE id = 1;'.format(self._temporary.FALSE, - self._temporary.TRUE)) + 'WHERE id = 1;'.format(self._testdb.FALSE, + self._testdb.TRUE)) # Complete the migration self._upgrade() with temporary_db(self._database): diff --git a/src/mailman/testing/testing.cfg b/src/mailman/testing/testing.cfg index 141d74a8f..0be01298b 100644 --- a/src/mailman/testing/testing.cfg +++ b/src/mailman/testing/testing.cfg @@ -18,9 +18,9 @@ # A testing configuration. # For testing against PostgreSQL. -# [database] -# class: mailman.database.postgresql.PostgreSQLDatabase -# url: postgres://barry:barry@localhost/mailman +[database] +class: mailman.database.postgresql.PostgreSQLDatabase +url: postgres://barry:barry@localhost/mailman [mailman] site_owner: noreply@example.com |
