blob: 78f1b6b9a9573c4fc93d81fb64b47cbed6f8a040 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# SPDX-License-Identifier: BSD-3-Clause
"""Test scheduled-task registration during consumer creation."""
import importlib
from unittest.mock import Mock
import pytest
from flask import Flask
from webmentions_ssg import huey
def test_consumer_registers_scanner_digest_reaper_and_retention(
app: Flask, monkeypatch: pytest.MonkeyPatch
) -> None:
import webmentions_ssg
app.config["SOURCE_SCAN_SCHEDULE"] = "*/15 * * * *"
app.config["DIGEST_SCHEDULE"] = "0 9 * * *"
app.config["VERIFICATION_RECOVERY_SCHEDULE"] = "*/3 * * * *"
app.config["RECEIVED_RETENTION_SCHEDULE"] = "0 4 * * *"
registered_tasks: list[object] = []
def register(_schedule: object):
def decorator(task: object) -> object:
registered_tasks.append(task)
return task
return decorator
periodic_task = Mock(side_effect=register)
monkeypatch.setattr(webmentions_ssg, "create_app", Mock(return_value=app))
monkeypatch.setattr(huey, "periodic_task", periodic_task)
consumer = importlib.import_module("webmentions_ssg.tasks.consumer")
from webmentions_ssg.tasks import notifications, receiver, retention, scanner
assert consumer.huey is huey.huey
assert periodic_task.call_count == 4
assert registered_tasks == [
scanner.scan_sources,
receiver.recover_stale_verifications,
notifications.send_webmention_digest,
retention.purge_old_received_webmentions,
]
|