@@ -76,6 +76,7 @@ def http_server_uds(request):
76
76
pytest .skip ("Platform does not support Unix domain sockets" )
77
77
78
78
uds_path = make_temp_maxlen_socket_path ()
79
+
79
80
def remove_uds_path ():
80
81
try :
81
82
os .remove (uds_path )
@@ -91,15 +92,15 @@ def remove_uds_path():
91
92
92
93
@pytest .fixture
93
94
def http_client (http_server ):
94
- return ipfshttpclient .http .ClientSync (
95
+ return ipfshttpclient .http .build_client_sync (
95
96
"/ip4/{0}/tcp/{1}/http" .format (* http_server .server_address ),
96
97
ipfshttpclient .DEFAULT_BASE ,
97
98
)
98
99
99
100
100
101
@pytest .fixture
101
102
def http_client_uds (http_server_uds ):
102
- return ipfshttpclient .http .ClientSync (
103
+ return ipfshttpclient .http .build_client_sync (
103
104
"/unix/{0}" .format (http_server_uds .server_address .lstrip ("/" )),
104
105
ipfshttpclient .DEFAULT_BASE ,
105
106
)
@@ -284,7 +285,7 @@ def test_failed_download(http_client, http_server):
284
285
285
286
def test_download_connect_error ():
286
287
"""Tests that a download from a non-existing server raises a ConnectionError."""
287
- http_client = ipfshttpclient .http .ClientSync (
288
+ http_client = ipfshttpclient .http .build_client_sync (
288
289
"/ip4/127.4.5.6/tcp/12393/http" ,
289
290
ipfshttpclient .DEFAULT_BASE
290
291
)
@@ -295,7 +296,7 @@ def test_download_connect_error():
295
296
296
297
def test_download_protocol_error (broken_http_server ):
297
298
"""Tests that a download from a server violating the HTTP protocol raises a ProtocolError."""
298
- http_client = ipfshttpclient .http .ClientSync (
299
+ http_client = ipfshttpclient .http .build_client_sync (
299
300
"/ip4/{0}/tcp/{1}/http" .format (* broken_http_server .server_address ),
300
301
ipfshttpclient .DEFAULT_BASE
301
302
)
@@ -306,7 +307,7 @@ def test_download_protocol_error(broken_http_server):
306
307
307
308
def test_download_timeout (slow_http_server ):
308
309
"""Tests that a timed-out download raises a TimeoutError."""
309
- http_client = ipfshttpclient .http .ClientSync (
310
+ http_client = ipfshttpclient .http .build_client_sync (
310
311
"/ip4/{0}/tcp/{1}/http" .format (* slow_http_server .server_address ),
311
312
ipfshttpclient .DEFAULT_BASE
312
313
)
@@ -317,7 +318,7 @@ def test_download_timeout(slow_http_server):
317
318
318
319
def test_download_timeout_session (slow_http_server ):
319
320
"""Tests that a timed-out download raises a TimeoutError."""
320
- http_client = ipfshttpclient .http .ClientSync (
321
+ http_client = ipfshttpclient .http .build_client_sync (
321
322
"/ip4/{0}/tcp/{1}/http" .format (* slow_http_server .server_address ),
322
323
ipfshttpclient .DEFAULT_BASE ,
323
324
timeout = 0.1
@@ -329,34 +330,37 @@ def test_download_timeout_session(slow_http_server):
329
330
330
331
def test_request_connect_error ():
331
332
"""Tests that a request to a non-existing server raises a ConnectionError."""
332
- http_client = ipfshttpclient .http .ClientSync (
333
+ http_client = ipfshttpclient .http .build_client_sync (
333
334
"/ip4/127.99.99.99/tcp/12393/http" ,
334
335
ipfshttpclient .DEFAULT_BASE
335
336
)
336
337
337
338
with pytest .raises (ipfshttpclient .exceptions .ConnectionError ):
338
339
http_client .download ('/any' )
339
340
341
+
340
342
def test_request_protocol_error (broken_http_server ):
341
343
"""Tests that a download from a server violating the HTTP protocol raises a ProtocolError."""
342
- http_client = ipfshttpclient .http .ClientSync (
344
+ http_client = ipfshttpclient .http .build_client_sync (
343
345
"/ip4/{0}/tcp/{1}/http" .format (* broken_http_server .server_address ),
344
346
ipfshttpclient .DEFAULT_BASE
345
347
)
346
348
347
349
with pytest .raises (ipfshttpclient .exceptions .ProtocolError ):
348
350
http_client .request ('/any' )
349
351
352
+
350
353
def test_request_timeout (slow_http_server ):
351
354
"""Tests that a timed-out request raises a TimeoutError."""
352
- http_client = ipfshttpclient .http .ClientSync (
355
+ http_client = ipfshttpclient .http .build_client_sync (
353
356
"/ip4/{0}/tcp/{1}/http" .format (* slow_http_server .server_address ),
354
357
ipfshttpclient .DEFAULT_BASE
355
358
)
356
359
357
360
with pytest .raises (ipfshttpclient .exceptions .TimeoutError ):
358
361
http_client .request ('/timeout' , timeout = 0.1 )
359
362
363
+
360
364
def test_session (http_client , http_server ):
361
365
"""Tests that a session is established and then closed."""
362
366
http_server .serve_content ("okay" , 200 )
0 commit comments