2023-07-23 14:24:22 -07:00
|
|
|
"""Extracts the dependencies of the components required for testing."""
|
2024-02-05 14:13:13 -08:00
|
|
|
|
2023-07-22 21:19:01 -07:00
|
|
|
from collections import defaultdict
|
2023-07-23 14:24:22 -07:00
|
|
|
from pathlib import Path
|
2023-07-22 21:19:01 -07:00
|
|
|
|
|
|
|
|
deps = defaultdict(list)
|
|
|
|
|
components, packages = [], []
|
|
|
|
|
|
2023-07-23 14:24:22 -07:00
|
|
|
requirements = Path("core") / "requirements_test_all.txt"
|
fix: replace deprecated `get_astral_location` with `get_astral_observer` (#1482)
* fix: replace deprecated get_astral_location with get_astral_observer (#1481)
HA 2026.7 deprecates homeassistant.helpers.sun.get_astral_location
(removal planned for 2027.7) in favor of get_astral_observer, causing a
deprecation warning in the HA logs.
- Switch SunEvents/SunLightSettings from astral.location.Location to
astral.Observer, using the astral.sun module functions (which return
UTC times by default, matching the previous local=False calls).
- Use get_astral_observer in switch.py, with a fallback for HA < 2026.7
that constructs the Observer directly from the HA config.
- Update tests and the webapp simulator accordingly.
* ci: handle removal of requirements_test_all.txt in HA 2026.8 dev
HA core removed requirements_test_all.txt (home-assistant/core#171530),
which made test_dependencies.py crash with FileNotFoundError and broke
the dev pytest job and the Docker builds. Fall back to
requirements_all.txt, which carries the same per-integration
'# homeassistant.components.x' annotations. Also extend the
aiohasupervisor pin lookup in scripts/setup-dependencies accordingly.
* test: support modern template light config for HA 2026.6+
HA 2026.6 removed the legacy `light: platform: template` YAML format
(home-assistant/core#169615), so setup_lights found no template platform
on HA dev and every test using it failed with IndexError. Detect legacy
support at runtime (PLATFORM_SCHEMA presence) and fall back to the
modern `template:` config format. The group platform is set up before
the template integration in the modern path, because setting up
`template` also sets up the `light` domain, which would make a later
async_setup_component(hass, LIGHT_DOMAIN, ...) a no-op.
2026-07-01 23:00:35 -07:00
|
|
|
if not requirements.exists():
|
|
|
|
|
# Removed from HA core in 2026.8 (home-assistant/core#171530); the same
|
|
|
|
|
# per-integration annotations live in requirements_all.txt.
|
|
|
|
|
requirements = Path("core") / "requirements_all.txt"
|
2023-07-23 14:24:22 -07:00
|
|
|
|
|
|
|
|
with requirements.open() as f:
|
2022-08-28 13:42:55 -07:00
|
|
|
lines = f.readlines()
|
|
|
|
|
|
2023-07-22 21:19:01 -07:00
|
|
|
for line in lines:
|
2023-07-23 14:24:22 -07:00
|
|
|
line = line.strip() # noqa: PLW2901
|
2023-07-22 21:19:01 -07:00
|
|
|
|
2022-08-28 13:42:55 -07:00
|
|
|
if line.startswith("# homeassistant."):
|
2023-07-22 21:19:01 -07:00
|
|
|
if components and packages:
|
|
|
|
|
for component in components:
|
|
|
|
|
deps[component].extend(packages)
|
|
|
|
|
components, packages = [], []
|
|
|
|
|
components.append(line.split("# homeassistant.")[1])
|
2022-08-28 13:42:55 -07:00
|
|
|
elif components and line:
|
|
|
|
|
packages.append(line)
|
2023-07-22 21:19:01 -07:00
|
|
|
|
|
|
|
|
# The last batch of components and packages
|
|
|
|
|
if components and packages:
|
|
|
|
|
for component in components:
|
|
|
|
|
deps[component].extend(packages)
|
2022-08-28 13:42:55 -07:00
|
|
|
|
2022-08-28 22:28:36 -07:00
|
|
|
required = [
|
|
|
|
|
"components.recorder",
|
|
|
|
|
"components.mqtt",
|
|
|
|
|
"components.zeroconf",
|
|
|
|
|
"components.http",
|
2022-11-06 12:30:20 -08:00
|
|
|
"components.stream",
|
2023-07-22 21:19:01 -07:00
|
|
|
"components.conversation", # only available after HA≥2023.2
|
2023-05-12 11:36:24 -07:00
|
|
|
"components.cloud",
|
2024-04-06 10:14:54 +02:00
|
|
|
"components.ffmpeg", # needed since 2024.1
|
2022-08-28 22:28:36 -07:00
|
|
|
]
|
2023-07-22 21:19:01 -07:00
|
|
|
to_install = [package for r in required for package in deps[r]]
|
2024-04-06 19:05:18 +02:00
|
|
|
to_install.append("flaky")
|
2023-07-22 21:19:01 -07:00
|
|
|
|
2023-07-23 14:24:22 -07:00
|
|
|
print(" ".join(to_install)) # noqa: T201
|