Skip to content

Commit

Permalink
Ignore created_at/modified_at in diagnosics snapshots (#3958)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Aug 12, 2024
1 parent 1c1bb0b commit cc53265
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions tests/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,38 @@
)
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(
"https://api.github.com/rate_limit",
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",
)

0 comments on commit cc53265

Please sign in to comment.