mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Fix dangerous-default-value warnings in cloudflare tests (#119598)
This commit is contained in:
parent
49b28cca62
commit
97e19cb61c
@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
import pycfdns
|
import pycfdns
|
||||||
|
|
||||||
from homeassistant.components.cloudflare.const import CONF_RECORDS, DOMAIN
|
from homeassistant.components.cloudflare.const import CONF_RECORDS, DOMAIN
|
||||||
from homeassistant.const import CONF_API_TOKEN, CONF_ZONE
|
from homeassistant.const import CONF_API_TOKEN, CONF_ZONE
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||||
|
|
||||||
from tests.common import MockConfigEntry
|
from tests.common import MockConfigEntry
|
||||||
|
|
||||||
@ -54,18 +57,18 @@ MOCK_ZONE_RECORDS: list[pycfdns.RecordModel] = [
|
|||||||
|
|
||||||
|
|
||||||
async def init_integration(
|
async def init_integration(
|
||||||
hass,
|
hass: HomeAssistant,
|
||||||
*,
|
*,
|
||||||
data: dict = ENTRY_CONFIG,
|
data: dict[str, Any] | UndefinedType = UNDEFINED,
|
||||||
options: dict = ENTRY_OPTIONS,
|
options: dict[str, Any] | UndefinedType = UNDEFINED,
|
||||||
unique_id: str = MOCK_ZONE["name"],
|
unique_id: str = MOCK_ZONE["name"],
|
||||||
skip_setup: bool = False,
|
skip_setup: bool = False,
|
||||||
) -> MockConfigEntry:
|
) -> MockConfigEntry:
|
||||||
"""Set up the Cloudflare integration in Home Assistant."""
|
"""Set up the Cloudflare integration in Home Assistant."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
domain=DOMAIN,
|
domain=DOMAIN,
|
||||||
data=data,
|
data=ENTRY_CONFIG if data is UNDEFINED else data,
|
||||||
options=options,
|
options=ENTRY_OPTIONS if options is UNDEFINED else options,
|
||||||
unique_id=unique_id,
|
unique_id=unique_id,
|
||||||
)
|
)
|
||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
@ -77,11 +80,18 @@ async def init_integration(
|
|||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
|
||||||
def _get_mock_client(zone: str = MOCK_ZONE, records: list = MOCK_ZONE_RECORDS):
|
def _get_mock_client(
|
||||||
|
zone: pycfdns.ZoneModel | UndefinedType = UNDEFINED,
|
||||||
|
records: list[pycfdns.RecordModel] | UndefinedType = UNDEFINED,
|
||||||
|
):
|
||||||
client: pycfdns.Client = AsyncMock()
|
client: pycfdns.Client = AsyncMock()
|
||||||
|
|
||||||
client.list_zones = AsyncMock(return_value=[zone])
|
client.list_zones = AsyncMock(
|
||||||
client.list_dns_records = AsyncMock(return_value=records)
|
return_value=[MOCK_ZONE if zone is UNDEFINED else zone]
|
||||||
|
)
|
||||||
|
client.list_dns_records = AsyncMock(
|
||||||
|
return_value=MOCK_ZONE_RECORDS if records is UNDEFINED else records
|
||||||
|
)
|
||||||
client.update_dns_record = AsyncMock(return_value=None)
|
client.update_dns_record = AsyncMock(return_value=None)
|
||||||
|
|
||||||
return client
|
return client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user