Add clock alarm scheduling with formatted alarm time options

This commit is contained in:
Jage9
2026-02-27 02:06:51 -05:00
parent 7eb94b3f12
commit 78be266fcf
9 changed files with 179 additions and 25 deletions

View File

@@ -282,6 +282,29 @@ async def test_clock_timezone_update_validates(monkeypatch: pytest.MonkeyPatch)
assert send_payloads[-1].ok is False
assert "timezone must be one of" in send_payloads[-1].message.lower()
await server._handle_message(
client,
json.dumps({"type": "item_update", "itemId": item.id, "params": {"alarmEnabled": True}}),
)
assert send_payloads[-1].ok is False
assert "alarmtime must be a valid time" in send_payloads[-1].message.lower()
await server._handle_message(
client,
json.dumps({"type": "item_update", "itemId": item.id, "params": {"alarmTime": "3:15 PM", "alarmEnabled": True}}),
)
assert send_payloads[-1].ok is True
assert item.params.get("alarmEnabled") is True
assert item.params.get("alarmTime") == "3:15 PM"
await server._handle_message(
client,
json.dumps({"type": "item_update", "itemId": item.id, "params": {"use24Hour": True}}),
)
assert send_payloads[-1].ok is True
assert item.params.get("use24Hour") is True
assert item.params.get("alarmTime") == "15:15"
@pytest.mark.asyncio
async def test_failed_wheel_use_does_not_consume_cooldown(monkeypatch: pytest.MonkeyPatch) -> None:

View File

@@ -167,6 +167,21 @@ async def test_item_secondary_use_missing_handler_returns_message(monkeypatch: p
assert "No secondary action" in results[-1].message
def test_clock_alarm_announcement_sequence_shape() -> None:
server = SignalingServer("127.0.0.1", 8765, None, None, grid_size=41)
params = {"timeZone": "America/Detroit", "use24Hour": False}
alarm_sounds = server._build_clock_announcement_sounds(params, top_of_hour=False, alarm=True)
assert alarm_sounds
assert alarm_sounds[0] == "/sounds/clock/el640/announcement.ogg"
assert alarm_sounds[-1] == "/sounds/clock/el640/alarm.ogg"
top_of_hour_sounds = server._build_clock_announcement_sounds(params, top_of_hour=True, alarm=False)
assert top_of_hour_sounds
assert top_of_hour_sounds[0] == "/sounds/clock/el640/hour1.ogg"
assert top_of_hour_sounds[-1] == "/sounds/clock/el640/hour2.ogg"
@pytest.mark.asyncio
async def test_auth_login_uses_hash_offload(monkeypatch: pytest.MonkeyPatch) -> None:
server = SignalingServer("127.0.0.1", 8765, None, None)