forked from opensafely-core/cohort-extractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_presto_utils.py
41 lines (35 loc) · 1.16 KB
/
test_presto_utils.py
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
from cohortextractor.presto_utils import presto_connection_params_from_url
def test_presto_connection_params_from_url_with_auth():
url = "presto://user:password@host:80/catalog/schema"
params = presto_connection_params_from_url(url)
auth = params.pop("auth")
assert auth._username == "user"
assert auth._password == "password"
assert params == {
"http_scheme": "http",
"user": "user",
"host": "host",
"port": 80,
"catalog": "catalog",
"schema": "schema",
}
def test_presto_connection_params_from_url_with_port_443():
url = "presto://host:443/catalog/schema"
assert presto_connection_params_from_url(url)== {
"http_scheme": "https",
"user": "ignored",
"host": "host",
"port": 443,
"catalog": "catalog",
"schema": "schema",
}
def test_presto_connection_params_from_url_with_no_port():
url = "presto://host/catalog/schema"
assert presto_connection_params_from_url(url)== {
"http_scheme": "http",
"user": "ignored",
"host": "host",
"port": 8080,
"catalog": "catalog",
"schema": "schema",
}