From cc532650706cf9ee5e03098033a456ab7b2642cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Mon, 12 Aug 2024 09:11:31 +0200 Subject: [PATCH] Ignore created_at/modified_at in diagnosics snapshots (#3958) --- tests/test_diagnostics.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/test_diagnostics.py b/tests/test_diagnostics.py index f1d4e8231d7..ab0afadac32 100644 --- a/tests/test_diagnostics.py +++ b/tests/test_diagnostics.py @@ -12,26 +12,26 @@ ) from tests.conftest import SnapshotFixture +REMOVE_KEYS = ("entry_id", "last_updated", "local", "minor_version", "created_at", "modified_at") + async def test_diagnostics(hacs: HacsBase, snapshots: SnapshotFixture): """Test the base result.""" diagnostics = await async_get_config_entry_diagnostics( - hacs.hass, hacs.configuration.config_entry, + hacs.hass, + hacs.configuration.config_entry, ) assert TOKEN not in str(diagnostics) snapshots.assert_match( - safe_json_dumps( - recursive_remove_key( - diagnostics, ("entry_id", "last_updated", "local", "minor_version"), - ), - ), - "diagnostics/base.json", + safe_json_dumps(recursive_remove_key(diagnostics, REMOVE_KEYS)), "diagnostics/base.json" ) async def test_diagnostics_with_exception( - hacs: HacsBase, snapshots: SnapshotFixture, response_mocker: ResponseMocker, + hacs: HacsBase, + snapshots: SnapshotFixture, + response_mocker: ResponseMocker, ): """Test the result with issues getting the ratelimit.""" response_mocker.add( @@ -39,14 +39,11 @@ async def test_diagnostics_with_exception( MockedResponse(status=400, content="Something went wrong"), ) diagnostics = await async_get_config_entry_diagnostics( - hacs.hass, hacs.configuration.config_entry, + hacs.hass, + hacs.configuration.config_entry, ) snapshots.assert_match( - safe_json_dumps( - recursive_remove_key( - diagnostics, ("entry_id", "last_updated", "local", "minor_version"), - ), - ), + safe_json_dumps(recursive_remove_key(diagnostics, REMOVE_KEYS)), "diagnostics/exception.json", )