Skip to content

Commit 167da43

Browse files
author
James William Pye
committed
Fix test_iri, add/remove tests, and correct handling of a zero length 'host'.
1 parent f6c985d commit 167da43

2 files changed

Lines changed: 62 additions & 257 deletions

File tree

postgresql/iri.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@
2525

2626
def structure(d, fieldproc = ri.unescape):
2727
'Create a clientparams dictionary from a parsed RI'
28-
if d.get('scheme', 'pq') != 'pq':
29-
raise ValueError("not a PQ-IRI")
30-
28+
if d.get('scheme', 'pq').lower() != 'pq':
29+
raise ValueError("PQ-IRI scheme is not 'pq'")
3130
cpd = {
3231
k : fieldproc(v) for k, v in d.items()
3332
if k not in ('path', 'fragment', 'query', 'host', 'scheme')
3433
}
34+
3535
path = d.get('path')
3636
frag = d.get('fragment')
3737
query = d.get('query')
3838
host = d.get('host')
3939

40-
if host:
40+
if host is not None:
4141
if host.startswith('[') and host.endswith(']'):
4242
host = host[1:-1]
4343
if host.startswith('unix:'):
@@ -124,7 +124,7 @@ def construct(x, obscure_password = False):
124124
else:
125125
host = None
126126
port = x.get('port')
127-
127+
128128
path = []
129129
if 'database' in x:
130130
path.append(x['database'])
@@ -135,7 +135,7 @@ def construct(x, obscure_password = False):
135135
if obscure_password and password is not None:
136136
password = '***'
137137
return (
138-
'pq',
138+
'pqs' if x.get('ssl', False) is True else 'pq',
139139
# netloc: user:pass@host[:port]
140140
ri.unsplit_netloc((
141141
x.get('user'),

0 commit comments

Comments
 (0)