Skip to content

Commit c4371fc

Browse files
committed
Add test for update pool kwags
1 parent abdf3db commit c4371fc

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

tests/client/test_serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_data_is_serialized():
7777

7878
def test_serialization_unsupported():
7979
"""Tests that when an object that is not serializable is given
80-
a type error is raised."""
80+
a type error is raised."""
8181
with pytest.raises(TypeError):
8282
json_dumps(type("d", (), {}))
8383

tests/client/test_utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import io
2+
import ssl
23
import tempfile
4+
from unittest.mock import patch
35

6+
import urllib3
7+
8+
from crate.client.http import _update_pool_kwargs_for_ssl_minimum_version
49
from crate.client.http import super_len
510

611

@@ -49,3 +54,30 @@ class Empty:
4954
pass
5055

5156
assert super_len(Empty()) is None
57+
58+
59+
def test_update_pool_kwargs_for_ssl_minimum_version():
60+
"""Test that the ssl_minimum_version is set correctly in the kwargs"""
61+
with patch.object(urllib3, "__version__", "2.0.0"):
62+
kwargs = {}
63+
_update_pool_kwargs_for_ssl_minimum_version(
64+
"https://example.com", kwargs
65+
)
66+
assert (
67+
kwargs.get("ssl_minimum_version")
68+
== ssl.TLSVersion.MINIMUM_SUPPORTED
69+
)
70+
71+
# not https
72+
kwargs = {}
73+
_update_pool_kwargs_for_ssl_minimum_version(
74+
"http://example.com", kwargs
75+
)
76+
assert "ssl_minimum_version" not in kwargs
77+
78+
with patch.object(urllib3, "__version__", "1.26.0"):
79+
kwargs = {}
80+
_update_pool_kwargs_for_ssl_minimum_version(
81+
"https://example.com", kwargs
82+
)
83+
assert "ssl_minimum_version" not in kwargs

0 commit comments

Comments
 (0)