summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r--test/dialect/postgresql/test_reflection.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index 4b5c4b949..7054a9fdd 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -1540,9 +1540,10 @@ class ReflectionTest(fixtures.TestBase):
)
def test_reflect_check_warning(self):
+ rows = [("some name", "NOTCHECK foobar")]
conn = mock.Mock(
- execute=lambda *arg, **kw: mock.Mock(
- fetchall=lambda: [("some name", "NOTCHECK foobar")]
+ execute=lambda *arg, **kw: mock.MagicMock(
+ fetchall=lambda: rows, __iter__=lambda self: iter(rows)
)
)
with mock.patch.object(
@@ -1553,6 +1554,30 @@ class ReflectionTest(fixtures.TestBase):
):
testing.db.dialect.get_check_constraints(conn, "foo")
+ def test_reflect_with_not_valid_check_constraint(self):
+ rows = [("some name", "CHECK ((a IS NOT NULL)) NOT VALID")]
+ conn = mock.Mock(
+ execute=lambda *arg, **kw: mock.MagicMock(
+ fetchall=lambda: rows, __iter__=lambda self: iter(rows)
+ )
+ )
+ with mock.patch.object(
+ testing.db.dialect, "get_table_oid", lambda *arg, **kw: 1
+ ):
+ check_constraints = testing.db.dialect.get_check_constraints(
+ conn, "foo"
+ )
+ eq_(
+ check_constraints,
+ [
+ {
+ "name": "some name",
+ "sqltext": "a IS NOT NULL",
+ "dialect_options": {"not_valid": True},
+ }
+ ],
+ )
+
class CustomTypeReflectionTest(fixtures.TestBase):
class CustomType(object):