From b490534657229cbc44f1f5735a39539ceaf776a3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 23 Aug 2014 15:21:16 -0400 Subject: - pep8 formatting for pg table opts feature, tests - add support for PG INHERITS - fix mis-named tests - changelog fixes #2051 --- test/dialect/postgresql/test_compiler.py | 95 ++++++++++++++++++++++++-------- 1 file changed, 73 insertions(+), 22 deletions(-) (limited to 'test/dialect/postgresql/test_compiler.py') diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 5d1fddb49..6c4f3c8cc 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -168,37 +168,88 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): def test_create_table_with_tablespace(self): m = MetaData() - tbl = Table('atable', m, Column("id", Integer), postgresql_tablespace = 'sometablespace') - self.assert_compile(schema.CreateTable(tbl), - "CREATE TABLE atable (id INTEGER)TABLESPACE sometablespace") + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_tablespace='sometablespace') + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) TABLESPACE sometablespace") + def test_create_table_with_tablespace_quoted(self): # testing quoting of tablespace name - tbl = Table('anothertable', m, Column("id", Integer), postgresql_tablespace = 'table') - self.assert_compile(schema.CreateTable(tbl), - 'CREATE TABLE anothertable (id INTEGER)TABLESPACE "table"') + m = MetaData() + tbl = Table( + 'anothertable', m, Column("id", Integer), + postgresql_tablespace='table') + self.assert_compile( + schema.CreateTable(tbl), + 'CREATE TABLE anothertable (id INTEGER) TABLESPACE "table"') + + def test_create_table_inherits(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_inherits='i1') + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) INHERITS ( i1 )") + + def test_create_table_inherits_tuple(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_inherits=('i1', 'i2')) + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) INHERITS ( i1, i2 )") + + def test_create_table_inherits_quoting(self): + m = MetaData() + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_inherits=('Quote Me', 'quote Me Too')) + self.assert_compile( + schema.CreateTable(tbl), + 'CREATE TABLE atable (id INTEGER) INHERITS ' + '( "Quote Me", "quote Me Too" )') def test_create_table_with_oids(self): m = MetaData() - tbl = Table('atable', m, Column("id", Integer), postgresql_with_oids = True, ) - self.assert_compile(schema.CreateTable(tbl), - "CREATE TABLE atable (id INTEGER)WITH OIDS") + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_with_oids=True, ) + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) WITH OIDS") - tbl2 = Table('anothertable', m, Column("id", Integer), postgresql_with_oids = False, ) - self.assert_compile(schema.CreateTable(tbl2), - "CREATE TABLE anothertable (id INTEGER)WITHOUT OIDS") + tbl2 = Table( + 'anothertable', m, Column("id", Integer), + postgresql_with_oids=False) + self.assert_compile( + schema.CreateTable(tbl2), + "CREATE TABLE anothertable (id INTEGER) WITHOUT OIDS") - def create_table_with_oncommit_option(self): + def test_create_table_with_oncommit_option(self): m = MetaData() - tbl = Table('atable', m, Column("id", Integer), postgresql_on_commit = "drop") - self.assert_compile(schema.CreateTable(tbl), - "CREATE TABLE atable (id INTEGER) ON COMMIT DROP") - - def create_table_with_multiple_options(self): + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_on_commit="drop") + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) ON COMMIT DROP") + + def test_create_table_with_multiple_options(self): m = MetaData() - tbl = Table('atable', m, Column("id", Integer), postgresql_tablespace = 'sometablespace', postgresql_with_oids = False, postgresql_on_commit = "preserve_rows") - self.assert_compile(schema.CreateTable(tbl), - "CREATE TABLE atable (id INTEGER)WITHOUT OIDS ON COMMIT PRESERVE ROWS TABLESPACE sometablespace") - + tbl = Table( + 'atable', m, Column("id", Integer), + postgresql_tablespace='sometablespace', + postgresql_with_oids=False, + postgresql_on_commit="preserve_rows") + self.assert_compile( + schema.CreateTable(tbl), + "CREATE TABLE atable (id INTEGER) WITHOUT OIDS " + "ON COMMIT PRESERVE ROWS TABLESPACE sometablespace") + def test_create_partial_index(self): m = MetaData() tbl = Table('testtbl', m, Column('data', Integer)) -- cgit v1.2.1