In this commit I added a few unittests to account for Foundations. There were
only a few tests I had to add to mediagoblin/tests/test_sql_migrations.py beca- -use the foundation creation only happens at database initialization.
This commit is contained in:
parent
63c3ca28ab
commit
860fa806ee
@ -58,8 +58,8 @@ class Level1(Base1):
|
|||||||
|
|
||||||
SET1_MODELS = [Creature1, Level1]
|
SET1_MODELS = [Creature1, Level1]
|
||||||
|
|
||||||
SET1_FOUNDATIONS = {Creature1:[{'name':u'goblin','num_legs':2,'is_demon':False},
|
FOUNDATIONS = {Creature1:[{'name':u'goblin','num_legs':2,'is_demon':False},
|
||||||
{'name':u'cerberus','num_legs':4,'is_demon':True}]}
|
{'name':u'cerberus','num_legs':4,'is_demon':True}]}
|
||||||
|
|
||||||
SET1_MIGRATIONS = {}
|
SET1_MIGRATIONS = {}
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ def test_set1_to_set3():
|
|||||||
|
|
||||||
printer = CollectingPrinter()
|
printer = CollectingPrinter()
|
||||||
migration_manager = MigrationManager(
|
migration_manager = MigrationManager(
|
||||||
u'__main__', SET1_MODELS, SET1_FOUNDATIONS, SET1_MIGRATIONS, Session(),
|
u'__main__', SET1_MODELS, FOUNDATIONS, SET1_MIGRATIONS, Session(),
|
||||||
printer)
|
printer)
|
||||||
|
|
||||||
# Check latest migration and database current migration
|
# Check latest migration and database current migration
|
||||||
@ -593,6 +593,7 @@ def test_set1_to_set3():
|
|||||||
assert migration_manager.latest_migration == 0
|
assert migration_manager.latest_migration == 0
|
||||||
assert migration_manager.database_current_migration == 0
|
assert migration_manager.database_current_migration == 0
|
||||||
|
|
||||||
|
|
||||||
# Install the initial set
|
# Install the initial set
|
||||||
# -----------------------
|
# -----------------------
|
||||||
|
|
||||||
@ -600,7 +601,7 @@ def test_set1_to_set3():
|
|||||||
|
|
||||||
# Try to "re-migrate" with same manager settings... nothing should happen
|
# Try to "re-migrate" with same manager settings... nothing should happen
|
||||||
migration_manager = MigrationManager(
|
migration_manager = MigrationManager(
|
||||||
u'__main__', SET1_MODELS, SET1_FOUNDATIONS, SET1_MIGRATIONS,
|
u'__main__', SET1_MODELS, FOUNDATIONS, SET1_MIGRATIONS,
|
||||||
Session(), printer)
|
Session(), printer)
|
||||||
assert migration_manager.init_or_migrate() == None
|
assert migration_manager.init_or_migrate() == None
|
||||||
|
|
||||||
@ -642,6 +643,20 @@ def test_set1_to_set3():
|
|||||||
# Now check to see if stuff seems to be in there.
|
# Now check to see if stuff seems to be in there.
|
||||||
session = Session()
|
session = Session()
|
||||||
|
|
||||||
|
# Check the creation of the foundation rows on the creature table
|
||||||
|
creature = session.query(Creature1).filter_by(
|
||||||
|
name=u'goblin').one()
|
||||||
|
assert creature.num_legs == 2
|
||||||
|
assert creature.is_demon == False
|
||||||
|
|
||||||
|
creature = session.query(Creature1).filter_by(
|
||||||
|
name=u'cerberus').one()
|
||||||
|
assert creature.num_legs == 4
|
||||||
|
assert creature.is_demon == True
|
||||||
|
|
||||||
|
|
||||||
|
# Check the creation of the inserted rows on the creature and levels tables
|
||||||
|
|
||||||
creature = session.query(Creature1).filter_by(
|
creature = session.query(Creature1).filter_by(
|
||||||
name=u'centipede').one()
|
name=u'centipede').one()
|
||||||
assert creature.num_legs == 100
|
assert creature.num_legs == 100
|
||||||
@ -682,7 +697,7 @@ def test_set1_to_set3():
|
|||||||
# isn't said to be updated yet
|
# isn't said to be updated yet
|
||||||
printer = CollectingPrinter()
|
printer = CollectingPrinter()
|
||||||
migration_manager = MigrationManager(
|
migration_manager = MigrationManager(
|
||||||
u'__main__', SET3_MODELS, SET3_MIGRATIONS, Session(),
|
u'__main__', SET3_MODELS, FOUNDATIONS, SET3_MIGRATIONS, Session(),
|
||||||
printer)
|
printer)
|
||||||
|
|
||||||
assert migration_manager.latest_migration == 8
|
assert migration_manager.latest_migration == 8
|
||||||
@ -709,7 +724,7 @@ def test_set1_to_set3():
|
|||||||
|
|
||||||
# Make sure version matches expected
|
# Make sure version matches expected
|
||||||
migration_manager = MigrationManager(
|
migration_manager = MigrationManager(
|
||||||
u'__main__', SET3_MODELS, SET3_MIGRATIONS, Session(),
|
u'__main__', SET3_MODELS, FOUNDATIONS, SET3_MIGRATIONS, Session(),
|
||||||
printer)
|
printer)
|
||||||
assert migration_manager.latest_migration == 8
|
assert migration_manager.latest_migration == 8
|
||||||
assert migration_manager.database_current_migration == 8
|
assert migration_manager.database_current_migration == 8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user