|
14 | 14 | from pytest_localserver.http import WSGIServer
|
15 | 15 | from werkzeug.wrappers import Request, Response
|
16 | 16 |
|
| 17 | +try: |
| 18 | + import httpcore |
| 19 | +except (ImportError, ModuleNotFoundError): |
| 20 | + httpcore = None |
| 21 | + |
17 | 22 | try:
|
18 | 23 | import gevent
|
19 | 24 | except ImportError:
|
@@ -274,6 +279,37 @@ def test_keep_alive_on_by_default(make_client):
|
274 | 279 | assert "socket_options" not in options
|
275 | 280 |
|
276 | 281 |
|
| 282 | +def test_default_timeout(make_client): |
| 283 | + client = make_client() |
| 284 | + |
| 285 | + options = client.transport._get_pool_options() |
| 286 | + assert "timeout" in options |
| 287 | + assert options["timeout"].total == client.transport.TIMEOUT |
| 288 | + |
| 289 | + |
| 290 | +@pytest.mark.skipif(not PY38, reason="HTTP2 libraries are only available in py3.8+") |
| 291 | +def test_default_timeout_http2(make_client): |
| 292 | + client = make_client(_experiments={"transport_http2": True}) |
| 293 | + |
| 294 | + with mock.patch( |
| 295 | + "sentry_sdk.transport.httpcore.ConnectionPool.request", |
| 296 | + return_value=httpcore.Response(200), |
| 297 | + ) as request_mock: |
| 298 | + sentry_sdk.get_global_scope().set_client(client) |
| 299 | + capture_message("hi") |
| 300 | + client.flush() |
| 301 | + |
| 302 | + request_mock.assert_called_once() |
| 303 | + assert request_mock.call_args.kwargs["extensions"] == { |
| 304 | + "timeout": { |
| 305 | + "pool": client.transport.TIMEOUT, |
| 306 | + "connect": client.transport.TIMEOUT, |
| 307 | + "write": client.transport.TIMEOUT, |
| 308 | + "read": client.transport.TIMEOUT, |
| 309 | + } |
| 310 | + } |
| 311 | + |
| 312 | + |
277 | 313 | @pytest.mark.skipif(not PY38, reason="HTTP2 libraries are only available in py3.8+")
|
278 | 314 | def test_http2_with_https_dsn(make_client):
|
279 | 315 | client = make_client(_experiments={"transport_http2": True})
|
|
0 commit comments