mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-01 20:29:00 +00:00
At dawn, dusk and night the environment shows the moon in the top-left corner of the scene, behind the plan: computed in the card from the home coordinates and the browser clock (short Meeus series + topocentric parallax, within 1.4° / 1.8 pp of JPL Horizons), one designer image under a continuous phase mask with the lit side always on the left (owner 2026-09-29), a feathered terminator, 3°/3 % thresholds and the 2 s fade of the window rays. Everything but a small gate lives in the lazy moon-runtime chunk, with its own 30 s ticker. General settings: "Sun" becomes "Sun and Moon" with one switch, on for new installations (DEFAULT_CONFIG), off for existing ones. The initial View graph sat 728 B under its budget: the gate is paid for by moving fifteen dialog-only strings of General settings into the lazy settings dictionary (#459) and by one build fingerprint literal instead of three, so the graph ends 4 B above dev. Golden: two new moon scenes, and the two General settings help frames show «Sun and Moon»; the WSL artifact test fixture now models scenes whose first capture awaits acceptance. Issue: #661 User-Visible: yes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018qZfe7YS4rqEMKoVeS3GKd
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
"""#661 AC9: `settings.moon`, the moon on the "Follow the Sun" background.
|
|
|
|
Pure subset (no Home Assistant, runs on Windows): the schema takes a strict
|
|
boolean, the support package copies only a boolean, new installations get the
|
|
moon switched on. The export/import round trip needs the integration package
|
|
and lives in test_ha_import_export.py.
|
|
"""
|
|
import pytest
|
|
import voluptuous as vol
|
|
|
|
from pure_imports import HOUSEPLAN_ROOT, load_pure
|
|
|
|
v = load_pure("hp_validation_moon", HOUSEPLAN_ROOT / "validation.py")
|
|
const = load_pure("custom_components.houseplan.const", HOUSEPLAN_ROOT / "const.py")
|
|
support = load_pure(
|
|
"custom_components.houseplan.support_package", HOUSEPLAN_ROOT / "support_package.py",
|
|
)
|
|
|
|
|
|
@pytest.mark.parametrize("value", [True, False])
|
|
def test_moon_accepts_a_boolean_and_keeps_it(value):
|
|
out = v.CONFIG_SCHEMA({"spaces": [], "settings": {"moon": value}})
|
|
assert out["settings"]["moon"] is value
|
|
|
|
|
|
@pytest.mark.parametrize("bad", ["yes", 1, 0, None, "true", [], {}])
|
|
def test_moon_rejects_everything_but_a_boolean(bad):
|
|
with pytest.raises(vol.Invalid):
|
|
v.CONFIG_SCHEMA({"spaces": [], "settings": {"moon": bad}})
|
|
|
|
|
|
def test_support_package_copies_only_a_boolean_moon():
|
|
assert support._global_settings({"moon": True}) == {"moon": True}
|
|
assert support._global_settings({"moon": False}) == {"moon": False}
|
|
for bad in ("true", 1, None):
|
|
assert "moon" not in support._global_settings({"moon": bad})
|
|
|
|
|
|
def test_new_installations_get_the_moon():
|
|
assert const.DEFAULT_CONFIG["settings"]["moon"] is True
|
|
assert v.CONFIG_SCHEMA(const.DEFAULT_CONFIG)["settings"]["moon"] is True
|