mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Use TypeVar defaults for Generator (#125228)
This commit is contained in:
parent
fbd3bf7a98
commit
c8fd48523f
@ -30,7 +30,7 @@ TEST_PROPERTY_VALUES = {
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.fujitsu_fglair.async_setup_entry", return_value=True
|
"homeassistant.components.fujitsu_fglair.async_setup_entry", return_value=True
|
||||||
|
@ -125,7 +125,7 @@ def mock_client_api(
|
|||||||
fixture_name: str,
|
fixture_name: str,
|
||||||
user_identifier: str,
|
user_identifier: str,
|
||||||
api_error: Exception,
|
api_error: Exception,
|
||||||
) -> Generator[Mock, None, None]:
|
) -> Generator[Mock]:
|
||||||
"""Set up fake Google Photos API responses from fixtures."""
|
"""Set up fake Google Photos API responses from fixtures."""
|
||||||
mock_api = AsyncMock(GooglePhotosLibraryApi, autospec=True)
|
mock_api = AsyncMock(GooglePhotosLibraryApi, autospec=True)
|
||||||
mock_api.get_user_info.return_value = UserInfoResult(
|
mock_api.get_user_info.return_value = UserInfoResult(
|
||||||
@ -136,9 +136,7 @@ def mock_client_api(
|
|||||||
|
|
||||||
responses = load_json_array_fixture(fixture_name, DOMAIN) if fixture_name else []
|
responses = load_json_array_fixture(fixture_name, DOMAIN) if fixture_name else []
|
||||||
|
|
||||||
async def list_media_items(
|
async def list_media_items(*args: Any) -> AsyncGenerator[ListMediaItemResult]:
|
||||||
*args: Any,
|
|
||||||
) -> AsyncGenerator[ListMediaItemResult, None, None]:
|
|
||||||
for response in responses:
|
for response in responses:
|
||||||
mock_list_media_items = Mock(ListMediaItemResult)
|
mock_list_media_items = Mock(ListMediaItemResult)
|
||||||
mock_list_media_items.media_items = [
|
mock_list_media_items.media_items = [
|
||||||
@ -163,9 +161,7 @@ def mock_client_api(
|
|||||||
# Emulate an async iterator for returning pages of response objects. We just
|
# Emulate an async iterator for returning pages of response objects. We just
|
||||||
# return a single page.
|
# return a single page.
|
||||||
|
|
||||||
async def list_albums(
|
async def list_albums(*args: Any, **kwargs: Any) -> AsyncGenerator[ListAlbumResult]:
|
||||||
*args: Any, **kwargs: Any
|
|
||||||
) -> AsyncGenerator[ListAlbumResult, None, None]:
|
|
||||||
mock_list_album_result = Mock(ListAlbumResult)
|
mock_list_album_result = Mock(ListAlbumResult)
|
||||||
mock_list_album_result.albums = [
|
mock_list_album_result.albums = [
|
||||||
Album.from_dict(album)
|
Album.from_dict(album)
|
||||||
|
@ -28,7 +28,7 @@ CLIENT_SECRET = "5678"
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="mock_setup")
|
@pytest.fixture(name="mock_setup")
|
||||||
def mock_setup_entry() -> Generator[Mock, None, None]:
|
def mock_setup_entry() -> Generator[Mock]:
|
||||||
"""Fixture to mock out integration setup."""
|
"""Fixture to mock out integration setup."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.google_photos.async_setup_entry", return_value=True
|
"homeassistant.components.google_photos.async_setup_entry", return_value=True
|
||||||
@ -37,7 +37,7 @@ def mock_setup_entry() -> Generator[Mock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def mock_patch_api(mock_api: Mock) -> Generator[None, None, None]:
|
def mock_patch_api(mock_api: Mock) -> Generator[None]:
|
||||||
"""Fixture to patch the config flow api."""
|
"""Fixture to patch the config flow api."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.google_photos.config_flow.GooglePhotosLibraryApi",
|
"homeassistant.components.google_photos.config_flow.GooglePhotosLibraryApi",
|
||||||
|
@ -34,7 +34,7 @@ from tests.common import MockConfigEntry, load_json_object_fixture
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Mock setting up a config entry."""
|
"""Mock setting up a config entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.intellifire.async_setup_entry", return_value=True
|
"homeassistant.components.intellifire.async_setup_entry", return_value=True
|
||||||
@ -43,7 +43,7 @@ def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_fireplace_finder_none() -> Generator[None, MagicMock, None]:
|
def mock_fireplace_finder_none() -> Generator[MagicMock]:
|
||||||
"""Mock fireplace finder."""
|
"""Mock fireplace finder."""
|
||||||
mock_found_fireplaces = Mock()
|
mock_found_fireplaces = Mock()
|
||||||
mock_found_fireplaces.ips = []
|
mock_found_fireplaces.ips = []
|
||||||
@ -110,7 +110,7 @@ def mock_common_data_local() -> IntelliFireCommonFireplaceData:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_apis_multifp(
|
def mock_apis_multifp(
|
||||||
mock_cloud_interface, mock_local_interface, mock_fp
|
mock_cloud_interface, mock_local_interface, mock_fp
|
||||||
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock], None, None]:
|
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock]]:
|
||||||
"""Multi fireplace version of mocks."""
|
"""Multi fireplace version of mocks."""
|
||||||
return mock_local_interface, mock_cloud_interface, mock_fp
|
return mock_local_interface, mock_cloud_interface, mock_fp
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ def mock_apis_multifp(
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_apis_single_fp(
|
def mock_apis_single_fp(
|
||||||
mock_cloud_interface, mock_local_interface, mock_fp
|
mock_cloud_interface, mock_local_interface, mock_fp
|
||||||
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock], None, None]:
|
) -> Generator[tuple[AsyncMock, AsyncMock, MagicMock]]:
|
||||||
"""Single fire place version of the mocks."""
|
"""Single fire place version of the mocks."""
|
||||||
data_v1 = IntelliFireUserData(
|
data_v1 = IntelliFireUserData(
|
||||||
**load_json_object_fixture("user_data_1.json", DOMAIN)
|
**load_json_object_fixture("user_data_1.json", DOMAIN)
|
||||||
@ -131,7 +131,7 @@ def mock_apis_single_fp(
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_cloud_interface() -> Generator[AsyncMock, None, None]:
|
def mock_cloud_interface() -> Generator[AsyncMock]:
|
||||||
"""Mock cloud interface to use for testing."""
|
"""Mock cloud interface to use for testing."""
|
||||||
user_data = IntelliFireUserData(
|
user_data = IntelliFireUserData(
|
||||||
**load_json_object_fixture("user_data_3.json", DOMAIN)
|
**load_json_object_fixture("user_data_3.json", DOMAIN)
|
||||||
@ -165,7 +165,7 @@ def mock_cloud_interface() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_local_interface() -> Generator[AsyncMock, None, None]:
|
def mock_local_interface() -> Generator[AsyncMock]:
|
||||||
"""Mock version of IntelliFireAPILocal."""
|
"""Mock version of IntelliFireAPILocal."""
|
||||||
poll_data = IntelliFirePollData(
|
poll_data = IntelliFirePollData(
|
||||||
**load_json_object_fixture("intellifire/local_poll.json")
|
**load_json_object_fixture("intellifire/local_poll.json")
|
||||||
@ -181,7 +181,7 @@ def mock_local_interface() -> Generator[AsyncMock, None, None]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_fp(mock_common_data_local) -> Generator[AsyncMock, None, None]:
|
def mock_fp(mock_common_data_local) -> Generator[AsyncMock]:
|
||||||
"""Mock fireplace."""
|
"""Mock fireplace."""
|
||||||
|
|
||||||
local_poll_data = IntelliFirePollData(
|
local_poll_data = IntelliFirePollData(
|
||||||
|
@ -39,14 +39,14 @@ def platforms() -> list[Platform]:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
async def mock_patch_platforms(platforms: list[str]) -> AsyncGenerator[None, None]:
|
async def mock_patch_platforms(platforms: list[str]) -> AsyncGenerator[None]:
|
||||||
"""Fixture to set up platforms for tests."""
|
"""Fixture to set up platforms for tests."""
|
||||||
with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms):
|
with patch(f"homeassistant.components.{DOMAIN}.PLATFORMS", platforms):
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||||
"""Override async_setup_entry."""
|
"""Override async_setup_entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.smlight.async_setup_entry", return_value=True
|
"homeassistant.components.smlight.async_setup_entry", return_value=True
|
||||||
|
@ -25,7 +25,7 @@ CLIENT_ID = "1"
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_setup_entry() -> Generator[Mock, None, None]:
|
def mock_setup_entry() -> Generator[Mock]:
|
||||||
"""Patch setup entry."""
|
"""Patch setup entry."""
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.yale.async_setup_entry", return_value=True
|
"homeassistant.components.yale.async_setup_entry", return_value=True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user