-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cda9bf7
commit 297c7c1
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"""Diagnostics support for Internet Printing Protocol (IPP).""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.core import HomeAssistant | ||
|
||
from .const import DOMAIN | ||
from .coordinator import IPPDataUpdateCoordinator | ||
|
||
|
||
async def async_get_config_entry_diagnostics( | ||
hass: HomeAssistant, config_entry: ConfigEntry | ||
) -> dict[str, Any]: | ||
"""Return diagnostics for a config entry.""" | ||
coordinator: IPPDataUpdateCoordinator = hass.data[DOMAIN][config_entry.entry_id] | ||
|
||
return { | ||
"entry": { | ||
"data": { | ||
**config_entry.data, | ||
}, | ||
"unique_id": config_entry.unique_id, | ||
}, | ||
"data": coordinator.data.as_dict(), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# serializer version: 1 | ||
# name: test_diagnostics | ||
dict({ | ||
'data': dict({ | ||
'info': dict({ | ||
'command_set': 'ESCPL2,BDC,D4,D4PX,ESCPR7,END4,GENEP,URF', | ||
'location': None, | ||
'manufacturer': 'TEST', | ||
'model': 'HA-1000 Series', | ||
'more_info': 'http://192.168.1.31:80/PRESENTATION/BONJOUR', | ||
'name': 'Test HA-1000 Series', | ||
'printer_info': 'Test HA-1000 Series', | ||
'printer_name': 'Test Printer', | ||
'printer_uri_supported': list([ | ||
'ipps://192.168.1.31:631/ipp/print', | ||
'ipp://192.168.1.31:631/ipp/print', | ||
]), | ||
'serial': '555534593035345555', | ||
'uptime': 30, | ||
'uuid': 'cfe92100-67c4-11d4-a45f-f8d027761251', | ||
'version': '20.23.06HA', | ||
}), | ||
'markers': list([ | ||
dict({ | ||
'color': '#000000', | ||
'high_level': 100, | ||
'level': 58, | ||
'low_level': 10, | ||
'marker_id': 0, | ||
'marker_type': 'ink-cartridge', | ||
'name': 'Black ink', | ||
}), | ||
dict({ | ||
'color': '#00FFFF', | ||
'high_level': 100, | ||
'level': 91, | ||
'low_level': 10, | ||
'marker_id': 2, | ||
'marker_type': 'ink-cartridge', | ||
'name': 'Cyan ink', | ||
}), | ||
dict({ | ||
'color': '#FF00FF', | ||
'high_level': 100, | ||
'level': 73, | ||
'low_level': 10, | ||
'marker_id': 4, | ||
'marker_type': 'ink-cartridge', | ||
'name': 'Magenta ink', | ||
}), | ||
dict({ | ||
'color': '#000000', | ||
'high_level': 100, | ||
'level': 98, | ||
'low_level': 10, | ||
'marker_id': 1, | ||
'marker_type': 'ink-cartridge', | ||
'name': 'Photo black ink', | ||
}), | ||
dict({ | ||
'color': '#FFFF00', | ||
'high_level': 100, | ||
'level': 95, | ||
'low_level': 10, | ||
'marker_id': 3, | ||
'marker_type': 'ink-cartridge', | ||
'name': 'Yellow ink', | ||
}), | ||
]), | ||
'state': dict({ | ||
'message': None, | ||
'printer_state': 'idle', | ||
'reasons': None, | ||
}), | ||
'uris': list([ | ||
dict({ | ||
'authentication': None, | ||
'security': 'tls', | ||
'uri': 'ipps://192.168.1.31:631/ipp/print', | ||
}), | ||
dict({ | ||
'authentication': None, | ||
'security': None, | ||
'uri': 'ipp://192.168.1.31:631/ipp/print', | ||
}), | ||
]), | ||
}), | ||
'entry': dict({ | ||
'data': dict({ | ||
'base_path': '/ipp/print', | ||
'host': '192.168.1.31', | ||
'port': 631, | ||
'ssl': False, | ||
'uuid': 'cfe92100-67c4-11d4-a45f-f8d027761251', | ||
'verify_ssl': True, | ||
}), | ||
'unique_id': 'cfe92100-67c4-11d4-a45f-f8d027761251', | ||
}), | ||
}) | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""Tests for the diagnostics data provided by the Internet Printing Protocol (IPP) integration.""" | ||
|
||
from syrupy import SnapshotAssertion | ||
|
||
from homeassistant.core import HomeAssistant | ||
|
||
from tests.common import MockConfigEntry | ||
from tests.components.diagnostics import get_diagnostics_for_config_entry | ||
from tests.typing import ClientSessionGenerator | ||
|
||
|
||
async def test_diagnostics( | ||
hass: HomeAssistant, | ||
hass_client: ClientSessionGenerator, | ||
init_integration: MockConfigEntry, | ||
snapshot: SnapshotAssertion, | ||
) -> None: | ||
"""Test diagnostics for config entry.""" | ||
assert ( | ||
await get_diagnostics_for_config_entry(hass, hass_client, init_integration) | ||
== snapshot | ||
) |