Move fixtures to decorators in netgear_lte tests (#119882)

This commit is contained in:
epenet 2024-06-18 12:40:06 +02:00 committed by GitHub
parent f5fd389512
commit a1a8d38181
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ from datetime import timedelta
from unittest.mock import patch from unittest.mock import patch
from eternalegypt.eternalegypt import Error from eternalegypt.eternalegypt import Error
import pytest
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from homeassistant.components.netgear_lte.const import DOMAIN from homeassistant.components.netgear_lte.const import DOMAIN
@ -18,7 +19,8 @@ from .conftest import CONF_DATA
from tests.common import async_fire_time_changed from tests.common import async_fire_time_changed
async def test_setup_unload(hass: HomeAssistant, setup_integration: None) -> None: @pytest.mark.usefixtures("setup_integration")
async def test_setup_unload(hass: HomeAssistant) -> None:
"""Test setup and unload.""" """Test setup and unload."""
entry = hass.config_entries.async_entries(DOMAIN)[0] entry = hass.config_entries.async_entries(DOMAIN)[0]
assert entry.state is ConfigEntryState.LOADED assert entry.state is ConfigEntryState.LOADED
@ -31,19 +33,18 @@ async def test_setup_unload(hass: HomeAssistant, setup_integration: None) -> Non
assert not hass.data.get(DOMAIN) assert not hass.data.get(DOMAIN)
async def test_async_setup_entry_not_ready( @pytest.mark.usefixtures("setup_cannot_connect")
hass: HomeAssistant, setup_cannot_connect: None async def test_async_setup_entry_not_ready(hass: HomeAssistant) -> None:
) -> None:
"""Test that it throws ConfigEntryNotReady when exception occurs during setup.""" """Test that it throws ConfigEntryNotReady when exception occurs during setup."""
entry = hass.config_entries.async_entries(DOMAIN)[0] entry = hass.config_entries.async_entries(DOMAIN)[0]
assert len(hass.config_entries.async_entries(DOMAIN)) == 1 assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state is ConfigEntryState.SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
@pytest.mark.usefixtures("setup_integration")
async def test_device( async def test_device(
hass: HomeAssistant, hass: HomeAssistant,
device_registry: dr.DeviceRegistry, device_registry: dr.DeviceRegistry,
setup_integration: None,
snapshot: SnapshotAssertion, snapshot: SnapshotAssertion,
) -> None: ) -> None:
"""Test device info.""" """Test device info."""
@ -53,11 +54,8 @@ async def test_device(
assert device == snapshot assert device == snapshot
async def test_update_failed( @pytest.mark.usefixtures("entity_registry_enabled_by_default", "setup_integration")
hass: HomeAssistant, async def test_update_failed(hass: HomeAssistant) -> None:
entity_registry_enabled_by_default: None,
setup_integration: None,
) -> None:
"""Test coordinator throws UpdateFailed after failed update.""" """Test coordinator throws UpdateFailed after failed update."""
with patch( with patch(
"homeassistant.components.netgear_lte.eternalegypt.Modem.information", "homeassistant.components.netgear_lte.eternalegypt.Modem.information",