claude cisteni skillu remind

This commit is contained in:
lachtan
2026-06-10 08:35:31 +02:00
parent addd153e8f
commit edf823fc72
5 changed files with 261 additions and 88 deletions

View File

@@ -180,3 +180,80 @@ def test_add_random_validation(tmp_path, capsys):
captured = capsys.readouterr()
assert ret == 1
assert "window" in captured.err.lower() or "gap" in captured.err.lower()
def test_remove_by_id_disambiguates_duplicates(tmp_path, capsys):
db_path = tmp_path / "test.sqlite"
init_db(db_path)
_run(db_path, ["add", "--text", "drink water", "--cron", "0 9 * * *"])
_run(db_path, ["add", "--text", "drink water", "--cron", "0 10 * * *"])
capsys.readouterr()
ret = _run(db_path, ["remove", "--keyword", "drink water"])
captured = capsys.readouterr()
assert ret == 1
assert "ambiguous" in captured.err
ret = _run(db_path, ["remove", "--id", "1"])
captured = capsys.readouterr()
assert ret == 0
assert json.loads(captured.out)["removed"]["id"] == 1
# the second duplicate is still there
ret = _run(db_path, ["list"])
captured = capsys.readouterr()
assert "drink water" in captured.out
def test_resolve_requires_id_or_keyword(tmp_path, capsys):
db_path = tmp_path / "test.sqlite"
init_db(db_path)
ret = _run(db_path, ["remove"])
captured = capsys.readouterr()
assert ret == 1
assert "id or --keyword" in captured.err
def test_edit_replace_schedules_requires_new_schedule(tmp_path, capsys):
db_path = tmp_path / "test.sqlite"
init_db(db_path)
_run(db_path, ["add", "--text", "task", "--cron", "0 9 * * *"])
capsys.readouterr()
ret = _run(db_path, ["edit", "--keyword", "task", "--replace-schedules"])
captured = capsys.readouterr()
assert ret == 1
assert "replace-schedules" in captured.err
def test_delivered_lists_deliveries(tmp_path, capsys):
db_path = tmp_path / "test.sqlite"
init_db(db_path)
conn = get_db(db_path)
try:
conn.execute(
"INSERT INTO reminders (text, enabled, timezone, created_at, updated_at) VALUES ('took 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', '2026-06-01T09:00:00', '2026-06-01T09:00:01', 'delivered')",
(rid,),
)
conn.execute(
"INSERT INTO reminder_fires (reminder_id, schedule_id, schedule_type, fire_time, delivered_at, status, error_message) "
"VALUES (?, 1, 'cron', '2026-06-01T10:00:00', NULL, 'failed', 'boom')",
(rid,),
)
finally:
conn.close()
ret = _run(db_path, ["delivered", "--since", "2026-06-01"])
captured = capsys.readouterr()
assert ret == 0
assert "took pills" in captured.out
assert "2026-06-01T09:00:01" in captured.out
# failed fire is not reported as delivered
assert captured.out.count("took pills") == 1