claude cisteni skillu remind
This commit is contained in:
@@ -196,3 +196,45 @@ def test_delivery_failure_logged(tmp_path, capsys):
|
||||
assert "network down" in row["error_message"]
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_schedule_type_correct_despite_id_collision(tmp_path):
|
||||
"""A cron fire must record schedule_type='cron' even when schedule_cron.id collides
|
||||
with a schedule_at.id (each schedule table has its own AUTOINCREMENT sequence)."""
|
||||
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 ('at one', 1, 'Europe/Prague', 'now', 'now')"
|
||||
)
|
||||
rid_at = conn.execute("SELECT last_insert_rowid()").fetchone()[0]
|
||||
conn.execute(
|
||||
"INSERT INTO schedule_at (reminder_id, at_datetime) VALUES (?, ?)", (rid_at, "2030-01-01T00:00:00")
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO reminders (text, enabled, timezone, created_at, updated_at) VALUES ('cron one', 1, 'Europe/Prague', 'now', 'now')"
|
||||
)
|
||||
rid_cron = conn.execute("SELECT last_insert_rowid()").fetchone()[0]
|
||||
conn.execute(
|
||||
"INSERT INTO schedule_cron (reminder_id, cron_expr) VALUES (?, ?)", (rid_cron, "0 10 * * *")
|
||||
)
|
||||
# schedule_at.id and schedule_cron.id both equal 1 here — the collision the fix guards against.
|
||||
assert conn.execute("SELECT id FROM schedule_at").fetchone()["id"] == 1
|
||||
assert conn.execute("SELECT id FROM schedule_cron").fetchone()["id"] == 1
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
now = datetime(2026, 6, 10, 10, 0, 0)
|
||||
with patch.object(remind_send, "_send_telegram", return_value=None):
|
||||
_run_send(db_path, now)
|
||||
|
||||
conn = get_db(db_path)
|
||||
try:
|
||||
row = conn.execute(
|
||||
"SELECT schedule_type, status FROM reminder_fires WHERE reminder_id = ?", (rid_cron,)
|
||||
).fetchone()
|
||||
assert row["schedule_type"] == "cron"
|
||||
assert row["status"] == "delivered"
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
Reference in New Issue
Block a user