Add and check data functions for test_migrations 141

Before the 141 migration test is run, _prerun_141 populates the migrations
table with a generated uuid. The _check_141 function checks that
the uuid migrated properly down to 36 char.

Partially implements: blueprint migration-testing-with-data

Change-Id: I43b47f69a94720bf9487eb30576035493700ddca
This commit is contained in:
Kurt Taylor
2013-02-08 16:12:13 -05:00
parent c2b771c0d1
commit af80c50edc

View File

@@ -47,6 +47,7 @@ import datetime
import os
import sqlalchemy
import urlparse
import uuid
from migrate.versioning import repository
@@ -440,6 +441,24 @@ class TestMigrations(BaseMigrationTestCase):
self.assertEqual(data[0]['mac'], bw['mac'])
# migration 141, update migrations instance uuid
def _prerun_141(self, engine):
data = {
'instance_uuid': str(uuid.uuid4())
}
migrations = get_table(engine, 'migrations')
engine.execute(migrations.insert(), data)
result = migrations.insert().values(data).execute()
data['id'] = result.inserted_primary_key[0]
return data
def _check_141(self, engine, data):
migrations = get_table(engine, 'migrations')
row = migrations.select(
migrations.c.id == data['id']).execute().first()
# Check that change to String(36) went alright
self.assertEqual(data['instance_uuid'], row['instance_uuid'])
# migration 146, availability zone transition
def _prerun_146(self, engine):
data = {