Add type hints to integration tests (j-m) (#87704)

This commit is contained in:
epenet 2023-02-08 19:06:59 +01:00 committed by GitHub
parent 630028106a
commit f75ac17554
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
103 changed files with 605 additions and 417 deletions

View file

@ -10,6 +10,7 @@ import homeassistant.components.mfi.sensor as mfi
import homeassistant.components.sensor as sensor_component
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.const import UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
PLATFORM = mfi
@ -28,7 +29,7 @@ GOOD_CONFIG = {
}
async def test_setup_missing_config(hass):
async def test_setup_missing_config(hass: HomeAssistant) -> None:
"""Test setup with missing configuration."""
with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client:
config = {"sensor": {"platform": "mfi"}}
@ -36,21 +37,21 @@ async def test_setup_missing_config(hass):
assert not mock_client.called
async def test_setup_failed_login(hass):
async def test_setup_failed_login(hass: HomeAssistant) -> None:
"""Test setup with login failure."""
with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client:
mock_client.side_effect = FailedToLogin
assert not PLATFORM.setup_platform(hass, GOOD_CONFIG, None)
async def test_setup_failed_connect(hass):
async def test_setup_failed_connect(hass: HomeAssistant) -> None:
"""Test setup with connection failure."""
with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client:
mock_client.side_effect = requests.exceptions.ConnectionError
assert not PLATFORM.setup_platform(hass, GOOD_CONFIG, None)
async def test_setup_minimum(hass):
async def test_setup_minimum(hass: HomeAssistant) -> None:
"""Test setup with minimum configuration."""
with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client:
config = deepcopy(GOOD_CONFIG)
@ -63,7 +64,7 @@ async def test_setup_minimum(hass):
)
async def test_setup_with_port(hass):
async def test_setup_with_port(hass: HomeAssistant) -> None:
"""Test setup with port."""
with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client:
assert await async_setup_component(hass, COMPONENT.DOMAIN, GOOD_CONFIG)
@ -74,7 +75,7 @@ async def test_setup_with_port(hass):
)
async def test_setup_with_tls_disabled(hass):
async def test_setup_with_tls_disabled(hass: HomeAssistant) -> None:
"""Test setup without TLS."""
with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client:
config = deepcopy(GOOD_CONFIG)
@ -89,7 +90,7 @@ async def test_setup_with_tls_disabled(hass):
)
async def test_setup_adds_proper_devices(hass):
async def test_setup_adds_proper_devices(hass: HomeAssistant) -> None:
"""Test if setup adds devices."""
with mock.patch(
"homeassistant.components.mfi.sensor.MFiClient"