summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-08-13 17:42:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-08-13 17:42:33 -0400
commitf39767ad727fcc9493d41451d7112d4f3459e9c4 (patch)
tree0e5b9887deda1d484ca8c520d6f18ff94d852ab5 /test/dialect/postgresql/test_reflection.py
parenta0e0f4c289b46c0c9a051c08d7f9a1929e0e30ce (diff)
downloadsqlalchemy-f39767ad727fcc9493d41451d7112d4f3459e9c4.tar.gz
- public method name is get_enums()
- return a list of dicts like other methods do - don't combine 'schema' with 'name', leave them separate - support '*' argument so that we can retrieve cross-schema if needed - remove "conn" argument - use bound parameters for 'schema' in SQL - order by schema, name, label - adapt _load_enums changes to column reflection - changelog - module docs for get_enums() - add drop of enums to --dropfirst
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r--test/dialect/postgresql/test_reflection.py69
1 files changed, 57 insertions, 12 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index 26de23902..bab41b0f7 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -624,24 +624,69 @@ class ReflectionTest(fixtures.TestBase):
eq_(fk, fk_ref[fk['name']])
@testing.provide_metadata
- def test_inspect_enums_custom_schema(self):
+ def test_inspect_enums_schema(self):
conn = testing.db.connect()
- enum_type = postgresql.ENUM('sad', 'ok', 'happy', name='mood',
- metadata=self.metadata, schema='test_schema')
+ enum_type = postgresql.ENUM(
+ 'sad', 'ok', 'happy', name='mood',
+ schema='test_schema',
+ metadata=self.metadata)
enum_type.create(conn)
inspector = reflection.Inspector.from_engine(conn.engine)
- eq_(inspector.load_enums(conn, 'test_schema'), {
- u'test_schema.mood': {'labels': [u'sad', u'ok', u'happy']}})
+ eq_(
+ inspector.get_enums('test_schema'), [{
+ 'visible': False,
+ 'name': 'mood',
+ 'schema': 'test_schema',
+ 'labels': ['sad', 'ok', 'happy']
+ }])
@testing.provide_metadata
- def test_inspect_enums_schema(self):
- conn = testing.db.connect()
- enum_type = postgresql.ENUM('cat', 'dog', 'rat', name='pet',
+ def test_inspect_enums(self):
+ enum_type = postgresql.ENUM(
+ 'cat', 'dog', 'rat', name='pet', metadata=self.metadata)
+ enum_type.create(testing.db)
+ inspector = reflection.Inspector.from_engine(testing.db)
+ eq_(inspector.get_enums(), [
+ {
+ 'visible': True,
+ 'labels': ['cat', 'dog', 'rat'],
+ 'name': 'pet',
+ 'schema': 'public'
+ }])
+
+ @testing.provide_metadata
+ def test_inspect_enums_star(self):
+ enum_type = postgresql.ENUM(
+ 'cat', 'dog', 'rat', name='pet', metadata=self.metadata)
+ schema_enum_type = postgresql.ENUM(
+ 'sad', 'ok', 'happy', name='mood',
+ schema='test_schema',
metadata=self.metadata)
- enum_type.create(conn)
- inspector = reflection.Inspector.from_engine(conn.engine)
- eq_(inspector.load_enums(conn), {
- u'pet': {'labels': [u'cat', u'dog', u'rat']}})
+ enum_type.create(testing.db)
+ schema_enum_type.create(testing.db)
+ inspector = reflection.Inspector.from_engine(testing.db)
+
+ eq_(inspector.get_enums(), [
+ {
+ 'visible': True,
+ 'labels': ['cat', 'dog', 'rat'],
+ 'name': 'pet',
+ 'schema': 'public'
+ }])
+
+ eq_(inspector.get_enums('*'), [
+ {
+ 'visible': True,
+ 'labels': ['cat', 'dog', 'rat'],
+ 'name': 'pet',
+ 'schema': 'public'
+ },
+ {
+ 'visible': False,
+ 'name': 'mood',
+ 'schema': 'test_schema',
+ 'labels': ['sad', 'ok', 'happy']
+ }])
class CustomTypeReflectionTest(fixtures.TestBase):