Fix blocking I/O in mqtt tests (#121140)
This commit is contained in:
parent
c59fc4e3c7
commit
7002042119
1 changed files with 18 additions and 13 deletions
|
@ -1363,24 +1363,29 @@ EXCLUDED_MODULES = {
|
||||||
|
|
||||||
|
|
||||||
async def test_missing_discover_abbreviations(
|
async def test_missing_discover_abbreviations(
|
||||||
|
hass: HomeAssistant,
|
||||||
mqtt_mock_entry: MqttMockHAClientGenerator,
|
mqtt_mock_entry: MqttMockHAClientGenerator,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check MQTT platforms for missing abbreviations."""
|
"""Check MQTT platforms for missing abbreviations."""
|
||||||
await mqtt_mock_entry()
|
await mqtt_mock_entry()
|
||||||
missing = []
|
missing: list[str] = []
|
||||||
regex = re.compile(r"(CONF_[a-zA-Z\d_]*) *= *[\'\"]([a-zA-Z\d_]*)[\'\"]")
|
regex = re.compile(r"(CONF_[a-zA-Z\d_]*) *= *[\'\"]([a-zA-Z\d_]*)[\'\"]")
|
||||||
for fil in Path(mqtt.__file__).parent.rglob("*.py"):
|
|
||||||
if fil.name in EXCLUDED_MODULES:
|
def _add_missing():
|
||||||
continue
|
for fil in Path(mqtt.__file__).parent.rglob("*.py"):
|
||||||
with open(fil, encoding="utf-8") as file:
|
if fil.name in EXCLUDED_MODULES:
|
||||||
matches = re.findall(regex, file.read())
|
continue
|
||||||
missing.extend(
|
with open(fil, encoding="utf-8") as file:
|
||||||
f"{fil}: no abbreviation for {match[1]} ({match[0]})"
|
matches = re.findall(regex, file.read())
|
||||||
for match in matches
|
missing.extend(
|
||||||
if match[1] not in ABBREVIATIONS.values()
|
f"{fil}: no abbreviation for {match[1]} ({match[0]})"
|
||||||
and match[1] not in DEVICE_ABBREVIATIONS.values()
|
for match in matches
|
||||||
and match[0] not in ABBREVIATIONS_WHITE_LIST
|
if match[1] not in ABBREVIATIONS.values()
|
||||||
)
|
and match[1] not in DEVICE_ABBREVIATIONS.values()
|
||||||
|
and match[0] not in ABBREVIATIONS_WHITE_LIST
|
||||||
|
)
|
||||||
|
|
||||||
|
await hass.async_add_executor_job(_add_missing)
|
||||||
|
|
||||||
assert not missing
|
assert not missing
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue