|
15 | 15 | from homeassistant.config_entries import ConfigEntry |
16 | 16 | from homeassistant.core import HomeAssistant |
17 | 17 | from homeassistant.helpers import device_registry as dr |
| 18 | +from homeassistant.helpers.discovery_flow import DiscoveryKey |
18 | 19 | from tests.bluetooth import inject_bluetooth_service_info_bleak |
19 | 20 | from tests.conftest import MockBleakClient, MockBMS, mock_config |
20 | 21 |
|
21 | 22 | BT_ADAPTER: Final[dict[str, Any]] = { |
22 | 23 | "connections": {(BT_DOMAIN, "local")}, |
23 | | - "hw_version": 14, |
| 24 | + "hw_version": "14", |
24 | 25 | "manufacturer": "adapter mnf", |
25 | 26 | "model": "adapter model", |
26 | | - "model_id": 2, |
| 27 | + "model_id": "2", |
27 | 28 | "name": "mock adapter", |
28 | | - "sw_version": 3, |
| 29 | + "sw_version": "3", |
29 | 30 | } |
30 | 31 |
|
31 | 32 | BMS_DEV: Final[dict[str, Any]] = { |
@@ -81,7 +82,15 @@ async def test_diagnostics( |
81 | 82 | "type": "aiobmsble.bms.mock_BMS", |
82 | 83 | }, |
83 | 84 | "disabled_by": None, |
84 | | - "discovery_keys": {}, |
| 85 | + "discovery_keys": { |
| 86 | + "bluetooth": ( |
| 87 | + DiscoveryKey( |
| 88 | + domain="bluetooth", |
| 89 | + key="cc:cc:cc:cc:cc:cc", |
| 90 | + version=1, |
| 91 | + ), |
| 92 | + ), |
| 93 | + }, |
85 | 94 | "domain": DOMAIN, |
86 | 95 | "entry_id": REDACTED, |
87 | 96 | "minor_version": 0, |
@@ -135,10 +144,16 @@ async def test_diagnostics( |
135 | 144 | inject_bluetooth_service_info_bleak(hass, bt_discovery) |
136 | 145 | await ce.runtime_data._async_setup() |
137 | 146 | await ce.runtime_data.async_refresh() |
| 147 | + await hass.async_block_till_done(wait_background_tasks=True) |
138 | 148 |
|
139 | 149 | diag_data: dict[str, Any] = await async_get_config_entry_diagnostics( |
140 | 150 | hass, config_entry |
141 | 151 | ) |
| 152 | + # patch the modified_at timestamp to match the expected value, since it is generated at runtime |
| 153 | + expected_diag_data["config_entry"]["modified_at"] = ( |
| 154 | + expected_diag_data["config_entry"]["modified_at"][:20] |
| 155 | + + diag_data["config_entry"]["modified_at"][20:] |
| 156 | + ) |
142 | 157 |
|
143 | 158 | assert repr(diag_data.pop("advertisement_data")) == repr( |
144 | 159 | expected_diag_data.pop("advertisement_data") |
|
0 commit comments