From 864c48bf261e2c6c2902a7e330c15f6f236e2f5f Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Sun, 1 Oct 2023 15:23:16 +0300 Subject: [PATCH] Update unit tests --- requirements-test.txt | 1 - tests/test_api.py | 11 ++++++----- tests/test_entity.py | 3 +-- tests/test_sensor.py | 2 +- tests/test_weather.py | 3 ++- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 7dcb424..3917cd6 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,5 +1,4 @@ -r requirements.txt -asynctest~=0.13 flake8~=6.1 flake8-docstrings~=1.7 mypy==1.0.0 diff --git a/tests/test_api.py b/tests/test_api.py index 4fcf245..fbb773f 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -11,10 +11,9 @@ """ from http import HTTPStatus from typing import Any, Optional -from unittest.mock import patch +from unittest.mock import Mock, patch from aiohttp import ClientSession -from asynctest import CoroutineMock from pytest import raises from pytest_homeassistant_custom_component.common import load_fixture @@ -79,10 +78,12 @@ def test__get(): @patch("aiohttp.ClientSession.get") async def test__async_get_data(mock_get, caplog): """Test with valid location data.""" + + async def mock_coroutine(): + return "qwe" + mock_get.return_value.__aenter__.return_value.status = HTTPStatus.OK - mock_get.return_value.__aenter__.return_value.text = CoroutineMock( - return_value="qwe" - ) + mock_get.return_value.__aenter__.return_value.text = Mock(wraps=mock_coroutine) # caplog.clear() async with ClientSession() as client: diff --git a/tests/test_entity.py b/tests/test_entity.py index aa52b82..3eebdaa 100644 --- a/tests/test_entity.py +++ b/tests/test_entity.py @@ -1,6 +1,5 @@ """Tests for GisMeteo integration.""" - -from asynctest import Mock +from unittest.mock import Mock from custom_components.gismeteo import GismeteoDataUpdateCoordinator from custom_components.gismeteo.const import ( diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 13574c5..7d16b9e 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,6 +1,6 @@ """Tests for GisMeteo integration.""" +from unittest.mock import Mock -from asynctest import Mock from pytest_homeassistant_custom_component.common import assert_setup_component from custom_components.gismeteo import GismeteoDataUpdateCoordinator diff --git a/tests/test_weather.py b/tests/test_weather.py index c94d4d1..a3ea620 100644 --- a/tests/test_weather.py +++ b/tests/test_weather.py @@ -1,5 +1,6 @@ """Tests for GisMeteo integration.""" -from asynctest import Mock +from unittest.mock import Mock + from pytest_homeassistant_custom_component.common import assert_setup_component from custom_components.gismeteo import GismeteoDataUpdateCoordinator