"""Test Brother diagnostics."""

from datetime import datetime
import json
from unittest.mock import Mock, patch

from syrupy import SnapshotAssertion

from homeassistant.core import HomeAssistant
from homeassistant.util.dt import UTC

from . import init_integration

from tests.common import load_fixture
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator


async def test_entry_diagnostics(
    hass: HomeAssistant,
    hass_client: ClientSessionGenerator,
    snapshot: SnapshotAssertion,
) -> None:
    """Test config entry diagnostics."""
    entry = await init_integration(hass, skip_setup=True)

    test_time = datetime(2019, 11, 11, 9, 10, 32, tzinfo=UTC)
    with (
        patch("brother.Brother.initialize"),
        patch("brother.datetime", now=Mock(return_value=test_time)),
        patch(
            "brother.Brother._get_data",
            return_value=json.loads(load_fixture("printer_data.json", "brother")),
        ),
    ):
        await hass.config_entries.async_setup(entry.entry_id)
        await hass.async_block_till_done()

    result = await get_diagnostics_for_config_entry(hass, hass_client, entry)

    assert result == snapshot
