diff options
author | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-08-14 17:08:55 -0400 |
---|---|---|
committer | Rodrigo Menezes <rodrigo.menezes@moat.com> | 2014-08-14 17:08:55 -0400 |
commit | 8af9c7670e07037259dc89510559d34a4e7ccc6f (patch) | |
tree | 0c3a79ffbf82387177d1c236f4148731a0e06b4f /test/dialect/postgresql/test_reflection.py | |
parent | 649f06759d933f4aacdfbb302e845e2bcb5e7641 (diff) | |
parent | e2d05259caf2c7c033a0a9376c0d3b7a1b040183 (diff) | |
download | sqlalchemy-8af9c7670e07037259dc89510559d34a4e7ccc6f.tar.gz |
Merge branch 'master' of https://github.com/rclmenezes/sqlalchemy
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r-- | test/dialect/postgresql/test_reflection.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py index 313be0b37..678c35881 100644 --- a/test/dialect/postgresql/test_reflection.py +++ b/test/dialect/postgresql/test_reflection.py @@ -1,5 +1,6 @@ # coding: utf-8 +from sqlalchemy.engine import reflection from sqlalchemy.testing.assertions import eq_, assert_raises, \ AssertsExecutionResults from sqlalchemy.testing import fixtures @@ -722,6 +723,71 @@ class ReflectionTest(fixtures.TestBase): for fk in fks: eq_(fk, fk_ref[fk['name']]) + @testing.provide_metadata + def test_inspect_enums_schema(self): + conn = testing.db.connect() + 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.get_enums('test_schema'), [{ + 'visible': False, + 'name': 'mood', + 'schema': 'test_schema', + 'labels': ['sad', 'ok', 'happy'] + }]) + + @testing.provide_metadata + 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(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): |