5
5
""" SLL Context Tests """
6
6
7
7
import ssl
8
+ from collections import namedtuple
8
9
from unittest import mock
9
10
10
11
import mocket
13
14
import adafruit_connection_manager
14
15
from adafruit_connection_manager import WIZNET5K_SSL_SUPPORT_VERSION
15
16
17
+ SimpleNamespace = namedtuple ("SimpleNamespace" , "name version" )
18
+
16
19
17
20
def test_connect_esp32spi_https ( # pylint: disable=unused-argument
18
21
adafruit_esp32spi_socketpool_module ,
@@ -53,7 +56,9 @@ def test_connect_wiznet5k_https_not_supported( # pylint: disable=unused-argumen
53
56
mock_pool = mocket .MocketPool ()
54
57
radio = mocket .MockRadio .WIZNET5K ()
55
58
old_version = (WIZNET5K_SSL_SUPPORT_VERSION [0 ] - 1 , 0 , 0 )
56
- with mock .patch ("sys.implementation" , (None , old_version )):
59
+ with mock .patch (
60
+ "sys.implementation" , SimpleNamespace ("circuitpython" , old_version )
61
+ ):
57
62
ssl_context = adafruit_connection_manager .get_radio_ssl_context (radio )
58
63
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
59
64
@@ -69,6 +74,9 @@ def test_connect_wiznet5k_https_supported( # pylint: disable=unused-argument
69
74
adafruit_wiznet5k_with_ssl_socketpool_module ,
70
75
):
71
76
radio = mocket .MockRadio .WIZNET5K ()
72
- with mock .patch ("sys.implementation" , (None , WIZNET5K_SSL_SUPPORT_VERSION )):
77
+ with mock .patch (
78
+ "sys.implementation" ,
79
+ SimpleNamespace ("circuitpython" , WIZNET5K_SSL_SUPPORT_VERSION ),
80
+ ):
73
81
ssl_context = adafruit_connection_manager .get_radio_ssl_context (radio )
74
82
assert isinstance (ssl_context , ssl .SSLContext )
0 commit comments