Напоминалки: таблица reminders и CRUD в database.py
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -56,3 +56,30 @@ def test_marketing_subscribers(tmp_db):
|
||||
tmp_db.update_user_field(11, "consent_2", "Не согласен")
|
||||
subs = tmp_db.get_marketing_subscribers()
|
||||
assert 10 in subs and 11 not in subs
|
||||
|
||||
|
||||
def test_reminders_crud(tmp_db):
|
||||
rid = tmp_db.add_reminder("Продлить домен", "2027-03-15 09:00:00", "yearly", [1, 2], created_by=1)
|
||||
active = tmp_db.get_active_reminders()
|
||||
assert any(r["id"] == rid for r in active)
|
||||
r = next(r for r in active if r["id"] == rid)
|
||||
assert r["recipients"] == [1, 2] and r["recurrence"] == "yearly"
|
||||
|
||||
due = tmp_db.get_due_reminders("2027-03-15 09:00:00")
|
||||
assert any(r["id"] == rid for r in due)
|
||||
assert tmp_db.get_due_reminders("2027-03-14 09:00:00") == []
|
||||
|
||||
tmp_db.update_reminder_next_at(rid, "2028-03-15 09:00:00")
|
||||
r2 = next(r for r in tmp_db.get_active_reminders() if r["id"] == rid)
|
||||
assert r2["next_at"] == "2028-03-15 09:00:00"
|
||||
|
||||
tmp_db.deactivate_reminder(rid)
|
||||
assert not any(r["id"] == rid for r in tmp_db.get_active_reminders())
|
||||
|
||||
|
||||
def test_reminders_all_recipients_and_delete(tmp_db):
|
||||
rid = tmp_db.add_reminder("Оплатить сервер", "2027-01-01 09:00:00", "once", "all", created_by=1)
|
||||
r = next(r for r in tmp_db.get_active_reminders() if r["id"] == rid)
|
||||
assert r["recipients"] == "all"
|
||||
assert tmp_db.delete_reminder(rid)
|
||||
assert not tmp_db.delete_reminder(rid) # уже удалено, повторное удаление — False
|
||||
|
||||
Reference in New Issue
Block a user