|
14 | 14 | from unittest.mock import patch
|
15 | 15 |
|
16 | 16 | import httpretty
|
| 17 | +import pytest |
17 | 18 | from httpretty import httprettified
|
18 | 19 | from requests import Session
|
19 | 20 |
|
@@ -314,3 +315,26 @@ def test_description_is_none_when_cursor_is_not_executed():
|
314 | 315 | connection = Connection("sample_trino_cluster:443")
|
315 | 316 | with connection.cursor() as cursor:
|
316 | 317 | assert hasattr(cursor, 'description')
|
| 318 | + |
| 319 | + |
| 320 | +@pytest.mark.parametrize( |
| 321 | + "host, port, http_scheme_input_argument, http_scheme_set", |
| 322 | + [ |
| 323 | + # Infer from hostname |
| 324 | + ("https://mytrinoserver.domain:9999", None, None, constants.HTTPS), |
| 325 | + ("http://mytrinoserver.domain:9999", None, None, constants.HTTP), |
| 326 | + # Infer from port |
| 327 | + ("mytrinoserver.domain", constants.DEFAULT_TLS_PORT, None, constants.HTTPS), |
| 328 | + ("mytrinoserver.domain", constants.DEFAULT_PORT, None, constants.HTTP), |
| 329 | + # http_scheme parameter has higher precedence than port parameter |
| 330 | + ("mytrinoserver.domain", constants.DEFAULT_TLS_PORT, constants.HTTP, constants.HTTP), |
| 331 | + ("mytrinoserver.domain", constants.DEFAULT_PORT, constants.HTTPS, constants.HTTPS), |
| 332 | + # Set explicitly by http_scheme parameter |
| 333 | + ("mytrinoserver.domain", None, constants.HTTPS, constants.HTTPS), |
| 334 | + # Default |
| 335 | + ("mytrinoserver.domain", None, None, constants.HTTP), |
| 336 | + ], |
| 337 | +) |
| 338 | +def test_setting_http_scheme(host, port, http_scheme_input_argument, http_scheme_set): |
| 339 | + connection = Connection(host, port, http_scheme=http_scheme_input_argument) |
| 340 | + assert connection.http_scheme == http_scheme_set |
0 commit comments