-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest_sql.py
More file actions
61 lines (50 loc) · 1.26 KB
/
Copy pathtest_sql.py
File metadata and controls
61 lines (50 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pytest
import responses
from wayscript.integrations import sql
PSYCOPG2_EXPECTED = dict(
dbname="my_db",
user="zach",
password="very-secret-password",
host="host.docker.internal",
port=15432,
)
MSSQL_EXPECTED = {
"database": "my_db",
"password": "very-secret-password",
"port": 15432,
"server": "host.docker.internal",
"user": "zach",
}
MYSQL_EXPECTED = {
"database": "my_db",
"host": "host.docker.internal",
"password": "very-secret-password",
"port": 15432,
"user": "zach",
}
@responses.activate
@pytest.mark.parametrize(
"client_name,expected",
[
("psycopg2", PSYCOPG2_EXPECTED),
("mssql", MSSQL_EXPECTED),
("mysql", MYSQL_EXPECTED),
],
)
def test_get_connection_kwargs(
client_name,
expected,
patch_client_get_url,
workspace_integrations_detail_response_sql,
):
"""Test getting postgres client kwargs"""
responses.add(
responses.GET,
patch_client_get_url,
json=workspace_integrations_detail_response_sql,
status=200,
)
_id = workspace_integrations_detail_response_sql["id"]
function_name = f"get_{client_name}_connection_kwargs"
function = getattr(sql, function_name)
assert expected == function(_id)