Dalsi vlna cisteni /remind od Claude

This commit is contained in:
lachtan
2026-06-10 08:48:26 +02:00
parent edf823fc72
commit abdfd8c67d
9 changed files with 237 additions and 184 deletions

View File

@@ -1,11 +1,8 @@
import json
import os
import sqlite3
import sys
from datetime import datetime
from pathlib import Path
import pytest
SCRIPTS = Path(__file__).parent.parent / "scripts"
sys.path.insert(0, str(SCRIPTS))
@@ -39,7 +36,7 @@ def test_add_list(tmp_path, capsys):
ret = _run(db_path, ["list"])
captured = capsys.readouterr()
assert ret == 0
assert "drink water" in captured.out
assert "#1 drink water [enabled]" in captured.out
assert "cron: 0 9 * * *" in captured.out
@@ -77,7 +74,7 @@ def test_remove(tmp_path, capsys):
ret = _run(db_path, ["list"])
captured = capsys.readouterr()
assert captured.out.strip() == ""
assert "(no active reminders)" in captured.out
def test_remove_no_match(tmp_path, capsys):
@@ -257,3 +254,35 @@ def test_delivered_lists_deliveries(tmp_path, capsys):
assert "2026-06-01T09:00:01" in captured.out
# failed fire is not reported as delivered
assert captured.out.count("took pills") == 1
def test_delivered_defaults_to_today(tmp_path, capsys):
db_path = tmp_path / "test.sqlite"
init_db(db_path)
today = datetime.now(remind_edit.PRAGUE).date().isoformat()
conn = get_db(db_path)
try:
conn.execute(
"INSERT INTO reminders (text, enabled, timezone, created_at, updated_at) "
"VALUES ('today pills', 1, 'Europe/Prague', 'now', 'now')"
)
rid = conn.execute("SELECT last_insert_rowid()").fetchone()[0]
conn.execute(
"INSERT INTO reminder_fires (reminder_id, schedule_id, schedule_type, fire_time, delivered_at, status) "
"VALUES (?, 1, 'cron', ?, ?, 'delivered')",
(rid, f"{today}T09:00:00", f"{today}T09:00:01"),
)
# an older delivery must not show up when defaulting to today
conn.execute(
"INSERT INTO reminder_fires (reminder_id, schedule_id, schedule_type, fire_time, delivered_at, status) "
"VALUES (?, 1, 'cron', '2020-01-01T09:00:00', '2020-01-01T09:00:01', 'delivered')",
(rid,),
)
finally:
conn.close()
ret = _run(db_path, ["delivered"])
captured = capsys.readouterr()
assert ret == 0
assert captured.out.count("today pills") == 1
assert "2020-01-01" not in captured.out