From d9903c4cf985381002de8b923815b05dd24e0651 Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Sat, 17 Dec 2022 12:34:43 +0100 Subject: [PATCH] Bump `brother` and `pysnmplib` (#84107) * Bump brother version * Bump pysnmplib version * Update sensor platform * Update switch platform * Update tests * Bump brother Co-authored-by: J. Nick Koston --- homeassistant/components/brother/manifest.json | 2 +- homeassistant/components/snmp/manifest.json | 2 +- homeassistant/components/snmp/sensor.py | 9 ++++----- homeassistant/components/snmp/switch.py | 3 ++- requirements_all.txt | 4 ++-- requirements_test_all.txt | 4 ++-- tests/components/snmp/test_sensor.py | 5 ++++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/brother/manifest.json b/homeassistant/components/brother/manifest.json index 68922ecaeb3..acaa185bd4d 100644 --- a/homeassistant/components/brother/manifest.json +++ b/homeassistant/components/brother/manifest.json @@ -3,7 +3,7 @@ "name": "Brother Printer", "documentation": "https://www.home-assistant.io/integrations/brother", "codeowners": ["@bieniu"], - "requirements": ["brother==2.0.0"], + "requirements": ["brother==2.1.1"], "zeroconf": [ { "type": "_printer._tcp.local.", diff --git a/homeassistant/components/snmp/manifest.json b/homeassistant/components/snmp/manifest.json index 1ffcb04ebda..182f4aac544 100644 --- a/homeassistant/components/snmp/manifest.json +++ b/homeassistant/components/snmp/manifest.json @@ -2,7 +2,7 @@ "domain": "snmp", "name": "SNMP", "documentation": "https://www.home-assistant.io/integrations/snmp", - "requirements": ["pysnmplib==5.0.15"], + "requirements": ["pysnmplib==5.0.20"], "codeowners": [], "iot_class": "local_polling", "loggers": ["pyasn1", "pysmi", "pysnmp"] diff --git a/homeassistant/components/snmp/sensor.py b/homeassistant/components/snmp/sensor.py index a582eef01fa..7254b3b9cc4 100644 --- a/homeassistant/components/snmp/sensor.py +++ b/homeassistant/components/snmp/sensor.py @@ -132,10 +132,8 @@ async def async_setup_platform( UdpTransportTarget((host, port), timeout=DEFAULT_TIMEOUT), ContextData(), ] - - errindication, _, _, _ = await getCmd( - *request_args, ObjectType(ObjectIdentity(baseoid)) - ) + get_result = await getCmd(*request_args, ObjectType(ObjectIdentity(baseoid))) + errindication, _, _, _ = await get_result if errindication and not accept_errors: _LOGGER.error("Please check the details in the configuration file") @@ -194,9 +192,10 @@ class SnmpData: async def async_update(self): """Get the latest data from the remote SNMP capable host.""" - errindication, errstatus, errindex, restable = await getCmd( + get_result = await getCmd( *self._request_args, ObjectType(ObjectIdentity(self._baseoid)) ) + errindication, errstatus, errindex, restable = await get_result if errindication and not self._accept_errors: _LOGGER.error("SNMP error: %s", errindication) diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py index feb87e7e253..bd5078c4349 100644 --- a/homeassistant/components/snmp/switch.py +++ b/homeassistant/components/snmp/switch.py @@ -259,9 +259,10 @@ class SnmpSwitch(SwitchEntity): async def async_update(self) -> None: """Update the state.""" - errindication, errstatus, errindex, restable = await getCmd( + get_result = await getCmd( *self._request_args, ObjectType(ObjectIdentity(self._baseoid)) ) + errindication, errstatus, errindex, restable = await get_result if errindication: _LOGGER.error("SNMP error: %s", errindication) diff --git a/requirements_all.txt b/requirements_all.txt index 1c445aeca8c..619f96e4f12 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -476,7 +476,7 @@ boto3==1.20.24 broadlink==0.18.3 # homeassistant.components.brother -brother==2.0.0 +brother==2.1.1 # homeassistant.components.brottsplatskartan brottsplatskartan==0.0.1 @@ -1939,7 +1939,7 @@ pysmarty==0.8 pysml==0.0.8 # homeassistant.components.snmp -pysnmplib==5.0.15 +pysnmplib==5.0.20 # homeassistant.components.snooz pysnooz==0.8.3 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 344a02bb5a9..5740d0755f0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -386,7 +386,7 @@ boschshcpy==0.2.35 broadlink==0.18.3 # homeassistant.components.brother -brother==2.0.0 +brother==2.1.1 # homeassistant.components.brunt brunt==1.2.0 @@ -1374,7 +1374,7 @@ pysmartapp==0.3.3 pysmartthings==0.7.6 # homeassistant.components.snmp -pysnmplib==5.0.15 +pysnmplib==5.0.20 # homeassistant.components.snooz pysnooz==0.8.3 diff --git a/tests/components/snmp/test_sensor.py b/tests/components/snmp/test_sensor.py index 9f3a555c2d9..e34c2a1baaf 100644 --- a/tests/components/snmp/test_sensor.py +++ b/tests/components/snmp/test_sensor.py @@ -1,5 +1,6 @@ """SNMP sensor tests.""" +import asyncio from unittest.mock import MagicMock, Mock, patch import pytest @@ -15,9 +16,11 @@ def hlapi_mock(): """Mock out 3rd party API.""" mock_data = MagicMock() mock_data.prettyPrint = Mock(return_value="hello") + future = asyncio.get_event_loop().create_future() + future.set_result((None, None, None, [[mock_data]])) with patch( "homeassistant.components.snmp.sensor.getCmd", - return_value=(None, None, None, [[mock_data]]), + return_value=future, ): yield