From: Mike Bayer Date: Mon, 22 Aug 2016 15:22:28 +0000 (-0400) Subject: Move op tests for Postgresql to test_postgresql X-Git-Tag: rel_0_8_8~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67a0a2f00b470b17a095fbb1a7f36e2be0d3ecc2;p=thirdparty%2Fsqlalchemy%2Falembic.git Move op tests for Postgresql to test_postgresql This moves tests for op features specific to Postgresql. Note this does not include tests in test_op that make use of the postgresql backend just for "schema" support. Change-Id: I82b4326bbc3a2c520891214c8e8254da36bd8f2a --- diff --git a/tests/test_op.py b/tests/test_op.py index 814d98e2..a4ada7bd 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -32,16 +32,6 @@ class OpTest(TestBase): op.rename_table('t1', 't2', schema="foo") context.assert_("ALTER TABLE foo.t1 RENAME TO foo.t2") - def test_rename_table_postgresql(self): - context = op_fixture("postgresql") - op.rename_table('t1', 't2') - context.assert_("ALTER TABLE t1 RENAME TO t2") - - def test_rename_table_schema_postgresql(self): - context = op_fixture("postgresql") - op.rename_table('t1', 't2', schema="foo") - context.assert_("ALTER TABLE foo.t1 RENAME TO t2") - def test_create_index_no_expr_allowed(self): op_fixture() assert_raises_message( @@ -108,29 +98,6 @@ class OpTest(TestBase): context.assert_( "CREATE INDEX geocoded ON locations (lower(coordinates))") - @config.requirements.fail_before_sqla_080 - def test_create_index_postgresql_expressions(self): - context = op_fixture("postgresql") - op.create_index( - 'geocoded', - 'locations', - [text('lower(coordinates)')], - postgresql_where=text("locations.coordinates != Null")) - context.assert_( - "CREATE INDEX geocoded ON locations (lower(coordinates)) " - "WHERE locations.coordinates != Null") - - def test_create_index_postgresql_where(self): - context = op_fixture("postgresql") - op.create_index( - 'geocoded', - 'locations', - ['coordinates'], - postgresql_where=text("locations.coordinates != Null")) - context.assert_( - "CREATE INDEX geocoded ON locations (coordinates) " - "WHERE locations.coordinates != Null") - def test_add_column(self): context = op_fixture() op.add_column('t1', Column('c1', Integer, nullable=False)) diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index b9973c28..1724898f 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -19,8 +19,45 @@ from alembic.testing.env import staging_env, clear_staging_env, \ _no_sql_testing_config, write_script from alembic.testing.fixtures import capture_context_buffer from alembic.testing.fixtures import TestBase - +from alembic.testing.fixtures import op_fixture from alembic.testing import config +from alembic import op + + +class PostgresqlOpTest(TestBase): + + def test_rename_table_postgresql(self): + context = op_fixture("postgresql") + op.rename_table('t1', 't2') + context.assert_("ALTER TABLE t1 RENAME TO t2") + + def test_rename_table_schema_postgresql(self): + context = op_fixture("postgresql") + op.rename_table('t1', 't2', schema="foo") + context.assert_("ALTER TABLE foo.t1 RENAME TO t2") + + @config.requirements.fail_before_sqla_080 + def test_create_index_postgresql_expressions(self): + context = op_fixture("postgresql") + op.create_index( + 'geocoded', + 'locations', + [text('lower(coordinates)')], + postgresql_where=text("locations.coordinates != Null")) + context.assert_( + "CREATE INDEX geocoded ON locations (lower(coordinates)) " + "WHERE locations.coordinates != Null") + + def test_create_index_postgresql_where(self): + context = op_fixture("postgresql") + op.create_index( + 'geocoded', + 'locations', + ['coordinates'], + postgresql_where=text("locations.coordinates != Null")) + context.assert_( + "CREATE INDEX geocoded ON locations (coordinates) " + "WHERE locations.coordinates != Null") class PGOfflineEnumTest(TestBase):