aboutsummaryrefslogtreecommitdiff
path: root/tests/tasks/test_notifications.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-12 23:34:46 +0100
committerDennis Fink2026-11-12 23:37:08 +0100
commit52fc66cb5ff19bf0def001ae50acc1b465a0b977 (patch)
treee791fa3e6d9f9b1b6fdf697f821adc84d2a57f0b /tests/tasks/test_notifications.py
parentb439de2005b70ec3867d589d1f4c63b83441e620 (diff)
downloadwebmentions-ssg-52fc66cb5ff19bf0def001ae50acc1b465a0b977.tar.gz
webmentions-ssg-52fc66cb5ff19bf0def001ae50acc1b465a0b977.zip
fix(core): decouple task imports from app initialization
Keep stable lazy task handles that register against the active Huey backend so modules can be imported before app creation and survive backend reinitialization. Separate package metadata and the shared blueprint from application startup to remove import-order dependencies and keep build-time version lookup lightweight.
Diffstat (limited to 'tests/tasks/test_notifications.py')
-rw-r--r--tests/tasks/test_notifications.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/tasks/test_notifications.py b/tests/tasks/test_notifications.py
index 0254b19..f87fd47 100644
--- a/tests/tasks/test_notifications.py
+++ b/tests/tasks/test_notifications.py
@@ -9,8 +9,10 @@ from unittest.mock import patch
import pytest
from flask import Flask
+from huey.exceptions import TaskLockedException
from webmentions_ssg import db
+from webmentions_ssg.extensions import huey
from webmentions_ssg.models import ReceivedWebmention
@@ -128,3 +130,19 @@ def test_digest_skips_when_no_new_mentions(
notifications.send_webmention_digest()
send.assert_not_called()
+
+
+def test_digest_lock_uses_current_backend(
+ notifications: ModuleType, app: Flask
+) -> None:
+ """A digest imported before reinitialization uses the new backend's lock."""
+ with app.app_context():
+ previous_backend = huey.huey
+ huey.init_app(app)
+ assert huey.huey is not previous_backend
+
+ with (
+ huey.lock_task("send-webmention-digest"),
+ pytest.raises(TaskLockedException),
+ ):
+ notifications.send_webmention_digest()