summaryrefslogtreecommitdiff
path: root/test/dialect
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-06-19 14:10:47 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-06-19 14:10:47 -0400
commite625d2ea88f4ae3e0a667b3d2a904dafbd0421b9 (patch)
tree20d026818f04242d86e60f11d262f6016048ad0e /test/dialect
parent99ceed3e55e87c7aca9898359e68c90ecee7965c (diff)
downloadsqlalchemy-e625d2ea88f4ae3e0a667b3d2a904dafbd0421b9.tar.gz
- for #3455
- changelog - versionadded + reflink for new pg storage parameters doc - pep8ing - add additional tests to definitely check that the Index object is created all the way with the opts we want fixes #3455
Diffstat (limited to 'test/dialect')
-rw-r--r--test/dialect/postgresql/test_compiler.py12
-rw-r--r--test/dialect/postgresql/test_reflection.py57
2 files changed, 41 insertions, 28 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index 731141604..9fa5c9804 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -375,24 +375,22 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
tbl = Table('testtbl', m, Column('data', String))
idx1 = Index('test_idx1', tbl.c.data)
- idx2 = Index('test_idx2', tbl.c.data, postgresql_with={"fillfactor": 50})
+ idx2 = Index(
+ 'test_idx2', tbl.c.data, postgresql_with={"fillfactor": 50})
idx3 = Index('test_idx3', tbl.c.data, postgresql_using="gist",
postgresql_with={"buffering": "off"})
self.assert_compile(schema.CreateIndex(idx1),
'CREATE INDEX test_idx1 ON testtbl '
- '(data)',
- dialect=postgresql.dialect())
+ '(data)')
self.assert_compile(schema.CreateIndex(idx2),
'CREATE INDEX test_idx2 ON testtbl '
'(data) '
- 'WITH (fillfactor = 50)',
- dialect=postgresql.dialect())
+ 'WITH (fillfactor = 50)')
self.assert_compile(schema.CreateIndex(idx3),
'CREATE INDEX test_idx3 ON testtbl '
'USING gist (data) '
- 'WITH (buffering = off)',
- dialect=postgresql.dialect())
+ 'WITH (buffering = off)')
def test_create_index_expr_gets_parens(self):
m = MetaData()
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index ed8a88fd4..e72ddadad 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -679,18 +679,27 @@ class ReflectionTest(fixtures.TestBase):
metadata = self.metadata
- t1 = Table('t', metadata,
- Column('id', Integer, primary_key=True),
- Column('x', Integer)
- )
+ Table(
+ 't', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('x', Integer)
+ )
metadata.create_all()
- conn = testing.db.connect().execution_options(autocommit=True)
- conn.execute("CREATE INDEX idx1 ON t (x) WITH (fillfactor = 50)")
- ind = testing.db.dialect.get_indexes(conn, "t", None)
- eq_(ind, [{'unique': False, 'column_names': ['x'], 'name': 'idx1',
- 'dialect_options': {"postgresql_with": {"fillfactor": "50"}}}])
- conn.close()
+ with testing.db.connect().execution_options(autocommit=True) as conn:
+ conn.execute("CREATE INDEX idx1 ON t (x) WITH (fillfactor = 50)")
+
+ ind = testing.db.dialect.get_indexes(conn, "t", None)
+ eq_(ind, [{'unique': False, 'column_names': ['x'], 'name': 'idx1',
+ 'dialect_options':
+ {"postgresql_with": {"fillfactor": "50"}}}])
+
+ m = MetaData()
+ t1 = Table('t', m, autoload_with=conn)
+ eq_(
+ list(t1.indexes)[0].dialect_options['postgresql']['with'],
+ {"fillfactor": "50"}
+ )
@testing.provide_metadata
def test_index_reflection_with_access_method(self):
@@ -698,18 +707,24 @@ class ReflectionTest(fixtures.TestBase):
metadata = self.metadata
- t1 = Table('t', metadata,
- Column('id', Integer, primary_key=True),
- Column('x', ARRAY(Integer))
- )
+ Table(
+ 't', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('x', ARRAY(Integer))
+ )
metadata.create_all()
- conn = testing.db.connect().execution_options(autocommit=True)
- conn.execute("CREATE INDEX idx1 ON t USING gin (x)")
-
- ind = testing.db.dialect.get_indexes(conn, "t", None)
- eq_(ind, [{'unique': False, 'column_names': ['x'], 'name': 'idx1',
- 'dialect_options': {'postgresql_using': 'gin'}}])
- conn.close()
+ with testing.db.connect().execution_options(autocommit=True) as conn:
+ conn.execute("CREATE INDEX idx1 ON t USING gin (x)")
+
+ ind = testing.db.dialect.get_indexes(conn, "t", None)
+ eq_(ind, [{'unique': False, 'column_names': ['x'], 'name': 'idx1',
+ 'dialect_options': {'postgresql_using': 'gin'}}])
+ m = MetaData()
+ t1 = Table('t', m, autoload_with=conn)
+ eq_(
+ list(t1.indexes)[0].dialect_options['postgresql']['using'],
+ 'gin'
+ )
@testing.provide_metadata
def test_foreign_key_option_inspection(self):