(
hacs: HacsBase,
filename: str,
additional: dict[str, Any] | None = None,
)
| 257 | snapshot.snapshot_dir = "tests/snapshots" |
| 258 | |
| 259 | async def assert_hacs_data( |
| 260 | hacs: HacsBase, |
| 261 | filename: str, |
| 262 | additional: dict[str, Any] | None = None, |
| 263 | ): |
| 264 | await hacs.data.async_force_write() |
| 265 | downloaded = [ |
| 266 | f.replace(f"{hacs.core.config_path}", "/config") |
| 267 | for f in iglob(f"{hacs.core.config_path}/**", recursive=True) |
| 268 | if os.path.isfile(f) |
| 269 | ] |
| 270 | data = {} |
| 271 | stored_data = await async_load_from_store(hacs.hass, "data") |
| 272 | for key, value in stored_data["repositories"].items(): |
| 273 | data[key] = {} |
| 274 | for entry in value: |
| 275 | data[key][entry["id"]] = entry |
| 276 | |
| 277 | dashboard_resources: ResourceStorageCollection |
| 278 | try: |
| 279 | # Changed to 2025.2.0 |
| 280 | # Changed in https://github.com/home-assistant/core/pull/136313 |
| 281 | dashboard_resources = hacs.hass.data[LOVELACE_DOMAIN].resources |
| 282 | except AttributeError: |
| 283 | dashboard_resources = hacs.hass.data[LOVELACE_DOMAIN][ |
| 284 | "resources" |
| 285 | ] |
| 286 | |
| 287 | def _entity_state(entity: er.RegistryEntry) -> dict[str, Any]: |
| 288 | state = hacs.hass.states.get(entity.entity_id) |
| 289 | return { |
| 290 | "state": state.state if state else None, |
| 291 | "attributes": recursive_remove_key(state.attributes, ("display_precision", "update_percentage")) if state else None, |
| 292 | } |
| 293 | |
| 294 | snapshot.assert_match( |
| 295 | safe_json_dumps( |
| 296 | recursive_remove_key( |
| 297 | { |
| 298 | "_dashboard_resources": recursive_remove_key( |
| 299 | data=dashboard_resources.async_items(), |
| 300 | to_remove=("id",), |
| 301 | ), |
| 302 | "_data": data, |
| 303 | "_directory": sorted(f for f in downloaded if f not in IGNORED_BASE_FILES), |
| 304 | "_hacs": { |
| 305 | "system": asdict(hacs.system), |
| 306 | "status": asdict(hacs.status), |
| 307 | "stage": hacs.stage, |
| 308 | "configuration": { |
| 309 | "debug": hacs.configuration.debug, |
| 310 | "dev": hacs.configuration.dev, |
| 311 | }, |
| 312 | }, |
| 313 | "_entities": sorted( |
| 314 | ( |
| 315 | { |
| 316 | "entity_id": entity.entity_id, |
nothing calls this directly
no test coverage detected
searching dependent graphs…