aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-07-13 21:09:04 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-07-13 21:09:04 -0500
commit77fb1e13316ab229897fa1e83e39ce1765213812 (patch)
treed2a19fbc5c74a7bccc7c8fe7f0c34c8430a05558
parent511b10efda06f4a4933c936594d5d270bdd6824c (diff)
downloadmediagoblin-77fb1e13316ab229897fa1e83e39ce1765213812.tar.lz
mediagoblin-77fb1e13316ab229897fa1e83e39ce1765213812.tar.xz
mediagoblin-77fb1e13316ab229897fa1e83e39ce1765213812.zip
A couple of tests related to migrations_to_run()
Includes a test making sure an exception is raised if current_migration not set in database
-rw-r--r--mediagoblin/tests/test_migrations.py36
1 files changed, 35 insertions, 1 deletions
diff --git a/mediagoblin/tests/test_migrations.py b/mediagoblin/tests/test_migrations.py
index 527655bc..127b90e1 100644
--- a/mediagoblin/tests/test_migrations.py
+++ b/mediagoblin/tests/test_migrations.py
@@ -15,11 +15,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from nose.tools import assert_raises
from pymongo import Connection
from mediagoblin.tests.tools import (
install_fixtures_simple, assert_db_meets_expected)
-from mediagoblin.db.util import RegisterMigration, MigrationManager, ObjectId
+from mediagoblin.db.util import (
+ RegisterMigration, MigrationManager, ObjectId,
+ MissingCurrentMigration)
# This one will get filled with local migrations
TEST_MIGRATION_REGISTRY = {}
@@ -366,3 +369,34 @@ class TestMigrations(object):
"""
self.empty_migration_manager.install_migration_version_if_missing()
assert self.empty_migration_manager.database_current_migration() == 0
+
+ def test_migrations_to_run(self):
+ """
+ Make sure we get the right list of migrations to run
+ """
+ self.migration_manager.set_current_migration(0)
+
+ assert self.migration_manager.migrations_to_run() == [
+ (1, creature_add_magical_powers),
+ (2, creature_rename_num_legs_to_num_limbs),
+ (3, creature_remove_is_demon),
+ (4, level_exits_dict_to_list)]
+
+ self.migration_manager.set_current_migration(3)
+
+ assert self.migration_manager.migrations_to_run() == [
+ (4, level_exits_dict_to_list)]
+
+ self.migration_manager.set_current_migration(4)
+
+ assert self.migration_manager.migrations_to_run() == []
+
+
+ def test_no_migrations_raises_exception(self):
+ """
+ If we don't have the current migration set in the database,
+ this should error out.
+ """
+ assert_raises(
+ MissingCurrentMigration,
+ self.migration_manager.migrations_to_run)