mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Ensure diagnostics redaction can handle lists of lists (#65170)
* Ensure diagnostics redaction can handle lists of lists * Code review * Update homeassistant/components/diagnostics/util.py Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> * Code review * Typing * Revert "Typing" This reverts commit8a57f772ca. * New typing attempt * Revert "New typing attempt" This reverts commite26e4aae69. * Fix typing * Fix typing again * Add tests Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
33
tests/components/diagnostics/test_util.py
Normal file
33
tests/components/diagnostics/test_util.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""Test Diagnostics utils."""
|
||||
from homeassistant.components.diagnostics import REDACTED, async_redact_data
|
||||
|
||||
|
||||
def test_redact():
|
||||
"""Test the async_redact_data helper."""
|
||||
data = {
|
||||
"key1": "value1",
|
||||
"key2": ["value2_a", "value2_b"],
|
||||
"key3": [["value_3a", "value_3b"], ["value_3c", "value_3d"]],
|
||||
"key4": {
|
||||
"key4_1": "value4_1",
|
||||
"key4_2": ["value4_2a", "value4_2b"],
|
||||
"key4_3": [["value4_3a", "value4_3b"], ["value4_3c", "value4_3d"]],
|
||||
},
|
||||
}
|
||||
|
||||
to_redact = {
|
||||
"key1",
|
||||
"key3",
|
||||
"key4_1",
|
||||
}
|
||||
|
||||
assert async_redact_data(data, to_redact) == {
|
||||
"key1": REDACTED,
|
||||
"key2": ["value2_a", "value2_b"],
|
||||
"key3": REDACTED,
|
||||
"key4": {
|
||||
"key4_1": REDACTED,
|
||||
"key4_2": ["value4_2a", "value4_2b"],
|
||||
"key4_3": [["value4_3a", "value4_3b"], ["value4_3c", "value4_3d"]],
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user