Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new WIZNET5k SocketPool #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions adafruit_connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def create_fake_ssl_context(
* `Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor
<https://www.adafruit.com/product/4264>`_
"""
socket_pool.set_interface(iface)
if hasattr(socket_pool, "set_interface"):
socket_pool.set_interface(iface)
return _FakeSSLContext(iface)


Expand Down Expand Up @@ -126,7 +127,9 @@ def get_radio_socketpool(radio):
ssl_context = create_fake_ssl_context(pool, radio)

elif class_name == "WIZNET5K":
import adafruit_wiznet5k.adafruit_wiznet5k_socket as pool # pylint: disable=import-outside-toplevel
import adafruit_wiznet5k.adafruit_wiznet5k_socketpool as socketpool # pylint: disable=import-outside-toplevel

pool = socketpool.SocketPool(radio)

# Note: SSL/TLS connections are not supported by the Wiznet5k library at this time
ssl_context = create_fake_ssl_context(pool, radio)
Expand Down
11 changes: 8 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ def set_interface(iface):
sys.modules["adafruit_esp32spi.adafruit_esp32spi_socket"] = esp32spi_socket_module

wiznet5k_module = type(sys)("adafruit_wiznet5k")
wiznet5k_socket_module = type(sys)("adafruit_wiznet5k_socket")
wiznet5k_socket_module.set_interface = set_interface
wiznet5k_socketpool_module = type(sys)("adafruit_wiznet5k_socketpool")
wiznet5k_socketpool_module.SocketPool = mocket.MocketPool
wiznet5k_socketpool_module.SocketPool.__module__ = ( # pylint: disable=no-member
"adafruit_wiznet5k.adafruit_wiznet5k_socketpool"
)
sys.modules["adafruit_wiznet5k"] = wiznet5k_module
sys.modules["adafruit_wiznet5k.adafruit_wiznet5k_socket"] = wiznet5k_socket_module
sys.modules["adafruit_wiznet5k.adafruit_wiznet5k_socketpool"] = (
wiznet5k_socketpool_module
)
2 changes: 1 addition & 1 deletion tests/get_radio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_get_radio_socketpool_esp32spi():
def test_get_radio_socketpool_wiznet5k():
radio = mocket.MockRadio.WIZNET5K()
socket_pool = adafruit_connection_manager.get_radio_socketpool(radio)
assert socket_pool.__name__ == "adafruit_wiznet5k_socket"
assert socket_pool.__module__ == "adafruit_wiznet5k.adafruit_wiznet5k_socketpool"


def test_get_radio_socketpool_unsupported():
Expand Down
Loading