Files
thc-webhook/tests/test_main_scheduler.py
T
zwitschi a4c92470b6
Build and Deploy Docker Container / test (push) Successful in 37s
Build and Deploy Docker Container / build-and-deploy (push) Failing after 1m3s
feat: add maintenance module for message deletion and related utilities
feat: implement tests for maintenance functions and dashboard interactions
feat: add timezone and country tests for thctime module
2026-05-10 12:36:02 +02:00

26 lines
923 B
Python

import main
def test_main_exits_quickly(monkeypatch):
monkeypatch.setattr(main, "send_notification", lambda x: None)
monkeypatch.setattr(main, "start_dashboard", lambda: None)
monkeypatch.setattr(main.schedule, "run_pending", lambda: (
_ for _ in ()).throw(KeyboardInterrupt()))
monkeypatch.setattr(main.time, "sleep", lambda s: None)
monkeypatch.setenv("DISCORD_WEBHOOK_URL", "http://example.com/webhook")
main.WEBHOOK_URL = "http://example.com/webhook"
main.main()
def test_get_next_scheduled_event():
now = main.datetime(2025, 1, 1, 10, 14, 30)
nxt = main.get_next_scheduled_event(now)
assert nxt["type"] == "reminder"
assert nxt["at"].hour == 10 and nxt["at"].minute == 15
now = main.datetime(2025, 1, 1, 10, 50, 1)
nxt = main.get_next_scheduled_event(now)
assert nxt["type"] == "reminder"
assert nxt["at"].hour == 11 and nxt["at"].minute == 15