hass-core/tests/components/file/conftest.py
Jan Bouwhuis 55c4ba12f6
Migrate file integration to config entry (#116861)
* File integration entry setup

* Import to entry and tests

* Add config flow

* Exception handling and tests

* Add config flow tests

* Add issue for micration and deprecation

* Check whole entry data for uniqueness

* Revert changes change new notify entity

* Follow up on code review

* Keep name service option

* Also keep sensor name

* Make name unique

* Follow up comment

* No default timestamp needed

* Remove default name as it is already set

* Use links
2024-05-10 10:54:36 +02:00

34 lines
884 B
Python

"""Test fixtures for file platform."""
from collections.abc import Generator
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from homeassistant.core import HomeAssistant
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.file.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def is_allowed() -> bool:
"""Parameterize mock_is_allowed_path, default True."""
return True
@pytest.fixture
def mock_is_allowed_path(
hass: HomeAssistant, is_allowed: bool
) -> Generator[None, MagicMock]:
"""Mock is_allowed_path method."""
with patch.object(
hass.config, "is_allowed_path", return_value=is_allowed
) as allowed_path_mock:
yield allowed_path_mock