From ab8e2d92c83ec7ac9926ee122c01a4cb586b39c4 Mon Sep 17 00:00:00 2001
From: G Johansson <goran.johansson@shiftit.se>
Date: Tue, 24 Sep 2024 22:37:54 +0200
Subject: [PATCH] Add diagnostics to Workday (#126691)

---
 .../components/workday/diagnostics.py         | 18 +++++++
 .../workday/snapshots/test_diagnostics.ambr   | 48 +++++++++++++++++++
 tests/components/workday/test_diagnostics.py  | 28 +++++++++++
 3 files changed, 94 insertions(+)
 create mode 100644 homeassistant/components/workday/diagnostics.py
 create mode 100644 tests/components/workday/snapshots/test_diagnostics.ambr
 create mode 100644 tests/components/workday/test_diagnostics.py

diff --git a/homeassistant/components/workday/diagnostics.py b/homeassistant/components/workday/diagnostics.py
new file mode 100644
index 00000000000..84e5073ca5b
--- /dev/null
+++ b/homeassistant/components/workday/diagnostics.py
@@ -0,0 +1,18 @@
+"""Diagnostics support for Workday."""
+
+from __future__ import annotations
+
+from typing import Any
+
+from homeassistant.config_entries import ConfigEntry
+from homeassistant.core import HomeAssistant
+
+
+async def async_get_config_entry_diagnostics(
+    hass: HomeAssistant, entry: ConfigEntry
+) -> dict[str, Any]:
+    """Return diagnostics for a config entry."""
+
+    return {
+        "config_entry": entry,
+    }
diff --git a/tests/components/workday/snapshots/test_diagnostics.ambr b/tests/components/workday/snapshots/test_diagnostics.ambr
new file mode 100644
index 00000000000..f41b86b7f6d
--- /dev/null
+++ b/tests/components/workday/snapshots/test_diagnostics.ambr
@@ -0,0 +1,48 @@
+# serializer version: 1
+# name: test_diagnostics
+  dict({
+    'config_entry': dict({
+      'data': dict({
+      }),
+      'disabled_by': None,
+      'discovery_keys': dict({
+      }),
+      'domain': 'workday',
+      'entry_id': '1',
+      'minor_version': 1,
+      'options': dict({
+        'add_holidays': list([
+          '2022-12-01',
+          '2022-12-05,2022-12-15',
+        ]),
+        'country': 'DE',
+        'days_offset': 0,
+        'excludes': list([
+          'sat',
+          'sun',
+          'holiday',
+        ]),
+        'language': 'de',
+        'name': 'Workday Sensor',
+        'province': 'BW',
+        'remove_holidays': list([
+          '2022-12-04',
+          '2022-12-24,2022-12-26',
+        ]),
+        'workdays': list([
+          'mon',
+          'tue',
+          'wed',
+          'thu',
+          'fri',
+        ]),
+      }),
+      'pref_disable_new_entities': False,
+      'pref_disable_polling': False,
+      'source': 'user',
+      'title': 'Mock Title',
+      'unique_id': None,
+      'version': 1,
+    }),
+  })
+# ---
diff --git a/tests/components/workday/test_diagnostics.py b/tests/components/workday/test_diagnostics.py
new file mode 100644
index 00000000000..13206a361f1
--- /dev/null
+++ b/tests/components/workday/test_diagnostics.py
@@ -0,0 +1,28 @@
+"""Test Workday diagnostics."""
+
+from __future__ import annotations
+
+from syrupy.assertion import SnapshotAssertion
+from syrupy.filters import props
+
+from homeassistant.core import HomeAssistant
+
+from . import TEST_CONFIG_ADD_REMOVE_DATE_RANGE, init_integration
+
+from tests.components.diagnostics import get_diagnostics_for_config_entry
+from tests.typing import ClientSessionGenerator
+
+
+async def test_diagnostics(
+    hass: HomeAssistant,
+    hass_client: ClientSessionGenerator,
+    snapshot: SnapshotAssertion,
+) -> None:
+    """Test generating diagnostics for a config entry."""
+    entry = await init_integration(hass, TEST_CONFIG_ADD_REMOVE_DATE_RANGE)
+
+    diag = await get_diagnostics_for_config_entry(hass, hass_client, entry)
+
+    assert diag == snapshot(
+        exclude=props("full_features", "created_at", "modified_at"),
+    )
-- 
GitLab