Skip to content

Commit 31c2869

Browse files
committed
test(connection, transfer-protocol): ensure system table queries execute
1 parent d651229 commit 31c2869

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import typing
2+
from warnings import warn
3+
4+
import pytest
5+
6+
import redshift_connector
7+
from redshift_connector.config import ClientProtocolVersion
8+
9+
system_tables: typing.List[str] = [
10+
"pg_aggregate",
11+
"pg_am",
12+
"pg_amop",
13+
"pg_amproc",
14+
"pg_attrdef",
15+
"pg_attribute",
16+
"pg_cast",
17+
"pg_class",
18+
"pg_constraint",
19+
"pg_conversion",
20+
"pg_database",
21+
"pg_default_acl",
22+
"pg_depend",
23+
"pg_description",
24+
# "pg_index", # has unsupported type oids 22, 30
25+
"pg_inherits",
26+
"pg_language",
27+
"pg_largeobject",
28+
"pg_namespace",
29+
"pg_opclass",
30+
"pg_operator",
31+
# "pg_proc", # has unsupported type oid 30
32+
"pg_rewrite",
33+
"pg_shdepend",
34+
"pg_statistic",
35+
"pg_tablespace",
36+
# "pg_trigger", # has unsupported type oid 22
37+
"pg_type",
38+
"pg_group",
39+
"pg_indexes",
40+
"pg_locks",
41+
"pg_rules",
42+
"pg_settings",
43+
"pg_stats",
44+
"pg_tables",
45+
# "pg_user", # has unsupported type oid 702
46+
"pg_views",
47+
# "pg_authid",
48+
# "pg_auth_members",
49+
# "pg_collation",
50+
# "pg_db_role_setting",
51+
# "pg_enum",
52+
# "pg_extension",
53+
# "pg_foreign_data_wrapper",
54+
# "pg_foreign_server",
55+
# "pg_foreign_table",
56+
# "pg_largeobject_metadata",
57+
# "pg_opfamily",
58+
# "pg_pltemplate",
59+
# "pg_seclabel",
60+
# "pg_shdescription",
61+
# "pg_ts_config",
62+
# "pg_ts_config_map",
63+
# "pg_ts_dict",
64+
# "pg_ts_parser",
65+
# "pg_ts_template",
66+
# "pg_user_mapping",
67+
# "pg_available_extensions",
68+
# "pg_available_extension_versions",
69+
# "pg_cursors",
70+
# "pg_prepared_statements",
71+
# "pg_prepared_xacts",
72+
# "pg_roles",
73+
# "pg_seclabels",
74+
# "pg_shadow",
75+
# "pg_timezone_abbrevs",
76+
# "pg_timezone_names",
77+
# "pg_user_mappings",
78+
]
79+
80+
# this test ensures system tables can be queried without datatype
81+
# conversion issue. no validation of result set occurs.
82+
83+
84+
@pytest.mark.skip(reason="manual")
85+
@pytest.mark.parametrize("client_protocol", ClientProtocolVersion.list())
86+
@pytest.mark.parametrize("table_name", system_tables)
87+
def test_process_system_table_datatypes(db_kwargs, client_protocol, table_name):
88+
db_kwargs["client_protocol_version"] = client_protocol
89+
90+
with redshift_connector.connect(**db_kwargs) as conn:
91+
if conn._client_protocol_version != client_protocol:
92+
warn(
93+
"Requested client_protocol_version was not satisfied. Requested {} Got {}".format(
94+
client_protocol, conn._client_protocol_version
95+
)
96+
)
97+
with conn.cursor() as cursor:
98+
cursor.execute("select * from {}".format(table_name))

0 commit comments

Comments
 (0)