2023-03-16 20:05:01 -07:00
|
|
|
"""Tests for diagnostics platform of local calendar."""
|
|
|
|
import pytest
|
|
|
|
from syrupy.assertion import SnapshotAssertion
|
|
|
|
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
|
2023-04-05 19:57:09 -07:00
|
|
|
from .conftest import TEST_ENTITY, ClientFixture
|
2023-03-16 20:05:01 -07:00
|
|
|
|
2023-04-05 19:57:09 -07:00
|
|
|
from tests.common import MockConfigEntry
|
2023-03-16 20:05:01 -07:00
|
|
|
from tests.components.diagnostics import get_diagnostics_for_config_entry
|
2023-04-05 19:57:09 -07:00
|
|
|
from tests.typing import ClientSessionGenerator
|
2023-03-22 14:00:47 -10:00
|
|
|
|
|
|
|
|
2023-03-16 20:05:01 -07:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
async def setup_diag(hass):
|
|
|
|
"""Set up diagnostics platform."""
|
|
|
|
assert await async_setup_component(hass, "diagnostics", {})
|
|
|
|
|
|
|
|
|
2023-04-05 19:57:09 -07:00
|
|
|
@pytest.mark.freeze_time("2023-03-13 12:05:00-07:00")
|
2023-03-16 20:05:01 -07:00
|
|
|
async def test_empty_calendar(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
setup_integration: None,
|
2023-04-05 19:57:09 -07:00
|
|
|
hass_client: ClientSessionGenerator,
|
2023-03-16 20:05:01 -07:00
|
|
|
config_entry: MockConfigEntry,
|
|
|
|
snapshot: SnapshotAssertion,
|
|
|
|
) -> None:
|
|
|
|
"""Test diagnostics against an empty calendar."""
|
2023-04-05 19:57:09 -07:00
|
|
|
data = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
2023-03-16 20:05:01 -07:00
|
|
|
assert data == snapshot
|
|
|
|
|
|
|
|
|
2023-04-05 19:57:09 -07:00
|
|
|
@pytest.mark.freeze_time("2023-03-13 12:05:00-07:00")
|
2023-03-16 20:05:01 -07:00
|
|
|
async def test_api_date_time_event(
|
|
|
|
hass: HomeAssistant,
|
|
|
|
setup_integration: None,
|
|
|
|
config_entry: MockConfigEntry,
|
2023-04-05 19:57:09 -07:00
|
|
|
hass_client: ClientSessionGenerator,
|
|
|
|
ws_client: ClientFixture,
|
2023-03-16 20:05:01 -07:00
|
|
|
snapshot: SnapshotAssertion,
|
|
|
|
) -> None:
|
|
|
|
"""Test an event with a start/end date time."""
|
2023-04-05 19:57:09 -07:00
|
|
|
client = await ws_client()
|
2023-03-16 20:05:01 -07:00
|
|
|
await client.cmd_result(
|
|
|
|
"create",
|
|
|
|
{
|
|
|
|
"entity_id": TEST_ENTITY,
|
|
|
|
"event": {
|
|
|
|
"summary": "Bastille Day Party",
|
|
|
|
"dtstart": "1997-07-14T17:00:00+00:00",
|
|
|
|
"dtend": "1997-07-15T04:00:00+00:00",
|
|
|
|
"rrule": "FREQ=DAILY",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
2023-04-05 19:57:09 -07:00
|
|
|
data = await get_diagnostics_for_config_entry(hass, hass_client, config_entry)
|
2023-03-16 20:05:01 -07:00
|
|
|
assert data == snapshot
|