diff options
author | Jason Michalski <armooo@armooo.net> | 2011-12-17 20:25:04 +0100 |
---|---|---|
committer | Jason Michalski <armooo@armooo.net> | 2011-12-17 20:25:04 +0100 |
commit | 7a5148a30bf1a9f55eb26dc0d5737b2132bc6ee2 (patch) | |
tree | 57ea2e4b0fb04632894e1983e0d1d82c858455da /migrate | |
parent | 08310eec9df530affaa02570d0fb2d163335d81a (diff) | |
download | sqalchemy-migrate-7a5148a30bf1a9f55eb26dc0d5737b2132bc6ee2.tar.gz |
Fix excludeTablesgetDiffOfModelAgainstModel is not passing
excludeTables correctly
Fixes issue 140
Diffstat (limited to 'migrate')
-rw-r--r-- | migrate/tests/versioning/test_schemadiff.py | 30 | ||||
-rw-r--r-- | migrate/versioning/schemadiff.py | 2 |
2 files changed, 24 insertions, 8 deletions
diff --git a/migrate/tests/versioning/test_schemadiff.py b/migrate/tests/versioning/test_schemadiff.py index 0bfa902..31c9648 100644 --- a/migrate/tests/versioning/test_schemadiff.py +++ b/migrate/tests/versioning/test_schemadiff.py @@ -12,7 +12,6 @@ from migrate.tests import fixture class SchemaDiffBase(fixture.DB): level = fixture.DB.CONNECT - def _make_table(self,*cols,**kw): self.table = Table('xtable', self.meta, Column('id',Integer(), primary_key=True), @@ -32,16 +31,23 @@ class SchemaDiffBase(fixture.DB): td = diff.tables_different.values()[0] eq_(1,len(td.columns_different)) cd = td.columns_different.values()[0] + label_width = max(len(self.name1), len(self.name2)) eq_(('Schema diffs:\n' ' table with differences: xtable\n' ' column with differences: data\n' - ' model: %r\n' - ' database: %r')%( + ' %*s: %r\n' + ' %*s: %r')%( + label_width, + self.name1, cd.col_A, + label_width, + self.name2, cd.col_B ),str(diff)) class Test_getDiffOfModelAgainstDatabase(SchemaDiffBase): + name1 = 'model' + name2 = 'database' def _run_diff(self,**kw): return schemadiff.getDiffOfModelAgainstDatabase( @@ -53,7 +59,7 @@ class Test_getDiffOfModelAgainstDatabase(SchemaDiffBase): self._make_table(create=False) diff = self._run_diff() self.assertTrue(diff) - eq_('Schema diffs:\n tables missing from database: xtable', + eq_('Schema diffs:\n tables missing from %s: xtable' % self.name2, str(diff)) @fixture.usedb() @@ -62,7 +68,7 @@ class Test_getDiffOfModelAgainstDatabase(SchemaDiffBase): self.meta.clear() diff = self._run_diff() self.assertTrue(diff) - eq_('Schema diffs:\n tables missing from model: xtable', + eq_('Schema diffs:\n tables missing from %s: xtable' % self.name1, str(diff)) @fixture.usedb() @@ -82,7 +88,7 @@ class Test_getDiffOfModelAgainstDatabase(SchemaDiffBase): self.assertTrue(diff) eq_('Schema diffs:\n' ' table with differences: xtable\n' - ' database missing these columns: xcol', + ' %s missing these columns: xcol' % self.name2, str(diff)) @fixture.usedb() @@ -101,7 +107,7 @@ class Test_getDiffOfModelAgainstDatabase(SchemaDiffBase): self.assertTrue(diff) eq_('Schema diffs:\n' ' table with differences: xtable\n' - ' model missing these columns: xcol', + ' %s missing these columns: xcol' % self.name1, str(diff)) @fixture.usedb() @@ -207,3 +213,13 @@ class Test_getDiffOfModelAgainstDatabase(SchemaDiffBase): eq_('No schema diffs',str(diff)) self.assertFalse(diff) +class Test_getDiffOfModelAgainstModel(Test_getDiffOfModelAgainstDatabase): + name1 = 'metadataA' + name2 = 'metadataB' + + def _run_diff(self,**kw): + db_meta= MetaData() + db_meta.reflect(self.engine) + return schemadiff.getDiffOfModelAgainstModel( + self.meta, db_meta, **kw + ) diff --git a/migrate/versioning/schemadiff.py b/migrate/versioning/schemadiff.py index 04cf83e..f8d77e4 100644 --- a/migrate/versioning/schemadiff.py +++ b/migrate/versioning/schemadiff.py @@ -38,7 +38,7 @@ def getDiffOfModelAgainstModel(metadataA, metadataB, excludeTables=None): :return: object which will evaluate to :keyword:`True` if there \ are differences else :keyword:`False`. """ - return SchemaDiff(metadataA, metadataB, excludeTables) + return SchemaDiff(metadataA, metadataB, excludeTables=excludeTables) class ColDiff(object): |