testsAndMisc/python_pkg/wallpaper_rotator/tests/test_procedural.py
Krzysztof kuhy Rudnicki d502580e3f Dark wallpaper rotator: new style every 3 h
Six text-free styles (gradient, flow/Voronoi, habit heatmap, shutdown
clock, Earth day/night, plasma) replace the white i3 root. A 15-minute
systemd user timer picks a new random style per monitor every 3 hours,
unlike its previous one and the other monitor's; live styles refresh in
between. Also syncs i3/config with the live config and prunes the
oldest evidence artifact for the 60-file cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWX51FMD58yKUC1eYWf
2026-11-11 16:31:06 +01:00

40 lines
1.2 KiB
Python

"""Both procedural generators are reachable and render the requested size."""
from __future__ import annotations
from datetime import UTC, datetime
from pathlib import Path
import numpy as np
import pytest
from python_pkg.wallpaper_rotator import _style_procedural as _procedural
from python_pkg.wallpaper_rotator._context import RenderContext
_SIZE = (320, 180)
def _seed_choosing(generator: str) -> int:
"""First seed whose first draw makes ``render`` pick the wanted generator."""
return next(
seed
for seed in range(100)
if (np.random.default_rng(seed).random() < _procedural._FLOW_SHARE)
== (generator == "flow")
)
@pytest.mark.parametrize("generator", ["flow", "voronoi"])
def test_render_reaches_each_generator(generator: str) -> None:
ctx = RenderContext(
now=datetime(2026, 11, 11, tzinfo=UTC),
data_home=Path(),
earth_dir=Path(),
shutdown_conf=Path(),
)
rng = np.random.default_rng(_seed_choosing(generator))
expected = getattr(_procedural, f"_{generator}")(
_SIZE, np.random.default_rng(_seed_choosing(generator))
)
assert _procedural.render(ctx, _SIZE, rng).size == expected.size == _SIZE