All checks were successful
Build-Release-Image / Build-Image (linux/arm64) (push) Successful in 3m40s
Build-Release-Image / Build-Image (linux/amd64) (push) Successful in 4m7s
Build-Release-Image / Merge-Images (push) Successful in 22s
Build-Release-Image / Create-Release (push) Successful in 15s
Build-Release-Image / Notify (push) Successful in 17s
27 lines
727 B
Python
27 lines
727 B
Python
import arrow
|
|
|
|
from app.models import Notification
|
|
from tasks.cleanup_old_notifications import cleanup_old_notifications
|
|
from tests.utils import create_new_user
|
|
|
|
|
|
def test_cleanup_old_notifications():
|
|
Notification.filter().delete()
|
|
user = create_new_user()
|
|
now = arrow.now()
|
|
delete_id = Notification.create(
|
|
user_id=user.id,
|
|
created_at=now.shift(minutes=-1),
|
|
message="",
|
|
flush=True,
|
|
).id
|
|
keep_id = Notification.create(
|
|
user_id=user.id,
|
|
created_at=now.shift(minutes=+1),
|
|
message="",
|
|
flush=True,
|
|
).id
|
|
cleanup_old_notifications(now)
|
|
assert Notification.get(id=delete_id) is None
|
|
assert Notification.get(id=keep_id) is not None
|