- dogebot.depcheck: find lib packages whose requirements Red's venv shadows (Red appends Downloader's lib to sys.path). Catches the 2026-11-09 anyio/typing_extensions break; verified on the old lib. - dogesetup.after_update: run it after provisioning and every cog update, write the deps health record, dispatch dogebot_cogs_ready. - dogebot.health: /data/health/<check>.json for the Kuma push script. - cogs/selftest: after every cog update and on [p]selftest run, runs watch search + watch status + alignment as the owner in the test channel, renders a sample chart, and plays music at volume 0 in an empty voice channel; reports to the channel and health. - start.install_bundled_cogs ships every cog in cogs/; manifest loads selftest last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
2.9 KiB
Python
85 lines
2.9 KiB
Python
"""Cog requirements in Downloader's lib must work with Red's venv."""
|
|
|
|
from pathlib import Path
|
|
|
|
from distributions import dist
|
|
|
|
from dogebot.depcheck import Conflict, find_conflicts
|
|
|
|
|
|
def test_shadowed_requirement_is_a_conflict(tmp_path: Path) -> None:
|
|
"""The 2026-11-09 break: lib's anyio needs a newer typing_extensions.
|
|
|
|
lib has typing_extensions 4.16.0 too, but Red appends lib to sys.path,
|
|
so the venv's 4.13.2 is the one anyio gets.
|
|
"""
|
|
venv, lib = tmp_path / "venv", tmp_path / "lib"
|
|
dist(venv, "typing_extensions", "4.13.2")
|
|
dist(lib, "typing_extensions", "4.16.0")
|
|
dist(lib, "anyio", "4.16.0", "typing_extensions>=4.16.0")
|
|
|
|
assert find_conflicts(lib, [venv]) == [
|
|
Conflict(
|
|
"anyio",
|
|
"4.16.0",
|
|
"typing_extensions>=4.16.0",
|
|
"4.13.2",
|
|
)
|
|
]
|
|
|
|
|
|
def test_compatible_versions_pass(tmp_path: Path) -> None:
|
|
"""No conflict when the venv's copy satisfies the requirement."""
|
|
venv, lib = tmp_path / "venv", tmp_path / "lib"
|
|
dist(venv, "typing_extensions", "4.13.2")
|
|
dist(lib, "anyio", "4.14.2", "typing_extensions>=4.5")
|
|
|
|
assert find_conflicts(lib, [venv]) == []
|
|
|
|
|
|
def test_requirement_found_only_in_lib_is_checked(tmp_path: Path) -> None:
|
|
"""Packages Red doesn't have are taken from lib itself."""
|
|
venv, lib = tmp_path / "venv", tmp_path / "lib"
|
|
venv.mkdir()
|
|
dist(lib, "h11", "0.14.0")
|
|
dist(lib, "httpcore", "1.0.9", "h11>=0.16")
|
|
|
|
assert find_conflicts(lib, [venv]) == [
|
|
Conflict("httpcore", "1.0.9", "h11>=0.16", "0.14.0")
|
|
]
|
|
|
|
|
|
def test_missing_requirement_is_a_conflict(tmp_path: Path) -> None:
|
|
"""A requirement installed nowhere is reported as missing."""
|
|
venv, lib = tmp_path / "venv", tmp_path / "lib"
|
|
venv.mkdir()
|
|
dist(lib, "httpx", "0.28.1", "idna")
|
|
|
|
assert find_conflicts(lib, [venv]) == [
|
|
Conflict("httpx", "0.28.1", "idna", None)
|
|
]
|
|
|
|
|
|
def test_names_are_normalised(tmp_path: Path) -> None:
|
|
"""typing-extensions, typing_extensions and Typing.Extensions match."""
|
|
venv, lib = tmp_path / "venv", tmp_path / "lib"
|
|
dist(venv, "Typing.Extensions", "4.13.2")
|
|
dist(lib, "anyio", "4.14.2", "typing-extensions>=4.5")
|
|
|
|
assert find_conflicts(lib, [venv]) == []
|
|
|
|
|
|
def test_markers_and_extras_are_respected(tmp_path: Path) -> None:
|
|
"""Requirements for other Pythons or unrequested extras are skipped."""
|
|
venv, lib = tmp_path / "venv", tmp_path / "lib"
|
|
venv.mkdir()
|
|
dist(
|
|
lib,
|
|
"anyio",
|
|
"4.14.2",
|
|
'exceptiongroup>=1; python_version < "3.0"',
|
|
'trio>=0.26; extra == "trio"',
|
|
)
|
|
|
|
assert find_conflicts(lib, [venv]) == []
|