a4c92470b6
feat: implement tests for maintenance functions and dashboard interactions feat: add timezone and country tests for thctime module
26 lines
923 B
Python
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
|