Cleanup redundant fixtures and move all other hassio addon fixtures to be shared (#124437)
This commit is contained in:
parent
6e5e96b047
commit
51dba1eec3
3 changed files with 124 additions and 152 deletions
|
@ -14,6 +14,8 @@ from homeassistant.const import STATE_OFF, STATE_ON
|
|||
from homeassistant.core import HomeAssistant
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.components.hassio.addon_manager import AddonManager
|
||||
|
||||
from .conversation import MockAgent
|
||||
from .device_tracker.common import MockScanner
|
||||
from .light.common import MockLight
|
||||
|
@ -182,6 +184,15 @@ def mock_legacy_device_tracker_setup() -> Callable[[HomeAssistant, MockScanner],
|
|||
return mock_legacy_device_tracker_setup
|
||||
|
||||
|
||||
@pytest.fixture(name="addon_manager")
|
||||
def addon_manager_fixture(hass: HomeAssistant) -> AddonManager:
|
||||
"""Return an AddonManager instance."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_addon_manager
|
||||
|
||||
return mock_addon_manager(hass)
|
||||
|
||||
|
||||
@pytest.fixture(name="discovery_info")
|
||||
def discovery_info_fixture() -> Any:
|
||||
"""Return the discovery info from the supervisor."""
|
||||
|
@ -269,3 +280,57 @@ def start_addon_fixture() -> Generator[AsyncMock]:
|
|||
from .hassio.common import mock_start_addon
|
||||
|
||||
yield from mock_start_addon()
|
||||
|
||||
|
||||
@pytest.fixture(name="restart_addon")
|
||||
def restart_addon_fixture() -> Generator[AsyncMock]:
|
||||
"""Mock restart add-on."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_restart_addon
|
||||
|
||||
yield from mock_restart_addon()
|
||||
|
||||
|
||||
@pytest.fixture(name="stop_addon")
|
||||
def stop_addon_fixture() -> Generator[AsyncMock]:
|
||||
"""Mock stop add-on."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_stop_addon
|
||||
|
||||
yield from mock_stop_addon()
|
||||
|
||||
|
||||
@pytest.fixture(name="set_addon_options")
|
||||
def set_addon_options_fixture() -> Generator[AsyncMock]:
|
||||
"""Mock set add-on options."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_set_addon_options
|
||||
|
||||
yield from mock_set_addon_options()
|
||||
|
||||
|
||||
@pytest.fixture(name="uninstall_addon")
|
||||
def uninstall_addon_fixture() -> Generator[AsyncMock]:
|
||||
"""Mock uninstall add-on."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_uninstall_addon
|
||||
|
||||
yield from mock_uninstall_addon()
|
||||
|
||||
|
||||
@pytest.fixture(name="create_backup")
|
||||
def create_backup_fixture() -> Generator[AsyncMock]:
|
||||
"""Mock create backup."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_create_backup
|
||||
|
||||
yield from mock_create_backup()
|
||||
|
||||
|
||||
@pytest.fixture(name="update_addon")
|
||||
def update_addon_fixture() -> Generator[AsyncMock]:
|
||||
"""Mock update add-on."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from .hassio.common import mock_update_addon
|
||||
|
||||
yield from mock_update_addon()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue