mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 17:49:37 +01:00
Add exception-translations rule to quality_scale pytest validation (#131914)
* Add exception-translations rule to quality_scale pytest validation * Adjust * Return empty dict if file is missing * Fix * Improve typing * Address comments * Update tests/components/conftest.py * Update tests/components/conftest.py * Update tests/components/conftest.py --------- Co-authored-by: Robert Resch <robert@resch.dev>
This commit is contained in:
+29
-2
@@ -15,7 +15,7 @@ from collections.abc import (
|
||||
)
|
||||
from contextlib import asynccontextmanager, contextmanager, suppress
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from enum import Enum
|
||||
from enum import Enum, StrEnum
|
||||
import functools as ft
|
||||
from functools import lru_cache
|
||||
from io import StringIO
|
||||
@@ -108,7 +108,7 @@ from homeassistant.util.json import (
|
||||
from homeassistant.util.signal_type import SignalType
|
||||
import homeassistant.util.ulid as ulid_util
|
||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||
import homeassistant.util.yaml.loader as yaml_loader
|
||||
from homeassistant.util.yaml import load_yaml_dict, loader as yaml_loader
|
||||
|
||||
from .testing_config.custom_components.test_constant_deprecation import (
|
||||
import_deprecated_constant,
|
||||
@@ -122,6 +122,14 @@ CLIENT_ID = "https://example.com/app"
|
||||
CLIENT_REDIRECT_URI = "https://example.com/app/callback"
|
||||
|
||||
|
||||
class QualityScaleStatus(StrEnum):
|
||||
"""Source of core configuration."""
|
||||
|
||||
DONE = "done"
|
||||
EXEMPT = "exempt"
|
||||
TODO = "todo"
|
||||
|
||||
|
||||
async def async_get_device_automations(
|
||||
hass: HomeAssistant,
|
||||
automation_type: device_automation.DeviceAutomationType,
|
||||
@@ -1832,3 +1840,22 @@ def reset_translation_cache(hass: HomeAssistant, components: list[str]) -> None:
|
||||
for loaded_components in loaded_categories.values():
|
||||
for component_to_unload in components:
|
||||
loaded_components.pop(component_to_unload, None)
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_quality_scale(integration: str) -> dict[str, QualityScaleStatus]:
|
||||
"""Load quality scale for integration."""
|
||||
quality_scale_file = pathlib.Path(
|
||||
f"homeassistant/components/{integration}/quality_scale.yaml"
|
||||
)
|
||||
if not quality_scale_file.exists():
|
||||
return {}
|
||||
raw = load_yaml_dict(quality_scale_file)
|
||||
return {
|
||||
rule: (
|
||||
QualityScaleStatus(details)
|
||||
if isinstance(details, str)
|
||||
else QualityScaleStatus(details["status"])
|
||||
)
|
||||
for rule, details in raw["rules"].items()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user