From 32476a3fed939e476c59a0625eaa901c18363906 Mon Sep 17 00:00:00 2001 From: ollo69 <60491700+ollo69@users.noreply.github.com> Date: Mon, 8 Mar 2021 19:34:12 +0100 Subject: [PATCH] Fix AsusWRT wrong api call (#47522) --- CODEOWNERS | 2 +- homeassistant/components/asuswrt/config_flow.py | 2 +- homeassistant/components/asuswrt/manifest.json | 2 +- homeassistant/components/asuswrt/router.py | 2 +- tests/components/asuswrt/test_config_flow.py | 4 ++-- tests/components/asuswrt/test_sensor.py | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CODEOWNERS b/CODEOWNERS index b4498aecc271..bece933d9c8f 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -46,7 +46,7 @@ homeassistant/components/arcam_fmj/* @elupus homeassistant/components/arduino/* @fabaff homeassistant/components/arest/* @fabaff homeassistant/components/arris_tg2492lg/* @vanbalken -homeassistant/components/asuswrt/* @kennedyshead +homeassistant/components/asuswrt/* @kennedyshead @ollo69 homeassistant/components/atag/* @MatsNL homeassistant/components/aten_pe/* @mtdcr homeassistant/components/atome/* @baqs diff --git a/homeassistant/components/asuswrt/config_flow.py b/homeassistant/components/asuswrt/config_flow.py index b312d9b8186f..94b5fd0f691a 100644 --- a/homeassistant/components/asuswrt/config_flow.py +++ b/homeassistant/components/asuswrt/config_flow.py @@ -127,7 +127,7 @@ class AsusWrtFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): conf_protocol = user_input[CONF_PROTOCOL] if conf_protocol == PROTOCOL_TELNET: - await api.connection.disconnect() + api.connection.disconnect() return RESULT_SUCCESS async def async_step_user(self, user_input=None): diff --git a/homeassistant/components/asuswrt/manifest.json b/homeassistant/components/asuswrt/manifest.json index 744a05b9728e..ab739f1c7ec4 100644 --- a/homeassistant/components/asuswrt/manifest.json +++ b/homeassistant/components/asuswrt/manifest.json @@ -4,5 +4,5 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/asuswrt", "requirements": ["aioasuswrt==1.3.1"], - "codeowners": ["@kennedyshead"] + "codeowners": ["@kennedyshead", "@ollo69"] } diff --git a/homeassistant/components/asuswrt/router.py b/homeassistant/components/asuswrt/router.py index c94135423d83..4c92ee2ef677 100644 --- a/homeassistant/components/asuswrt/router.py +++ b/homeassistant/components/asuswrt/router.py @@ -341,7 +341,7 @@ class AsusWrtRouter: """Close the connection.""" if self._api is not None: if self._protocol == PROTOCOL_TELNET: - await self._api.connection.disconnect() + self._api.connection.disconnect() self._api = None for func in self._on_close: diff --git a/tests/components/asuswrt/test_config_flow.py b/tests/components/asuswrt/test_config_flow.py index 7faec5d336cc..a6e24b094621 100644 --- a/tests/components/asuswrt/test_config_flow.py +++ b/tests/components/asuswrt/test_config_flow.py @@ -1,6 +1,6 @@ """Tests for the AsusWrt config flow.""" from socket import gaierror -from unittest.mock import AsyncMock, patch +from unittest.mock import AsyncMock, Mock, patch import pytest @@ -46,7 +46,7 @@ def mock_controller_connect(): with patch("homeassistant.components.asuswrt.router.AsusWrt") as service_mock: service_mock.return_value.connection.async_connect = AsyncMock() service_mock.return_value.is_connected = True - service_mock.return_value.connection.disconnect = AsyncMock() + service_mock.return_value.connection.disconnect = Mock() yield service_mock diff --git a/tests/components/asuswrt/test_sensor.py b/tests/components/asuswrt/test_sensor.py index 334f06d85a61..4a8a1f27653d 100644 --- a/tests/components/asuswrt/test_sensor.py +++ b/tests/components/asuswrt/test_sensor.py @@ -1,6 +1,6 @@ """Tests for the AsusWrt sensor.""" from datetime import timedelta -from unittest.mock import AsyncMock, patch +from unittest.mock import AsyncMock, Mock, patch from aioasuswrt.asuswrt import Device import pytest @@ -49,7 +49,7 @@ def mock_controller_connect(): with patch("homeassistant.components.asuswrt.router.AsusWrt") as service_mock: service_mock.return_value.connection.async_connect = AsyncMock() service_mock.return_value.is_connected = True - service_mock.return_value.connection.disconnect = AsyncMock() + service_mock.return_value.connection.disconnect = Mock() service_mock.return_value.async_get_connected_devices = AsyncMock( return_value=MOCK_DEVICES )