aboutsummaryrefslogtreecommitdiff
path: root/tests/test_init.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/test_init.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 '')
-rw-r--r--tests/test_init.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_init.py b/tests/test_init.py
index 7112654..ccfdfd8 100644
--- a/tests/test_init.py
+++ b/tests/test_init.py
@@ -4,6 +4,9 @@
"""Test application initialization and its public integrations."""
+import subprocess
+import sys
+
from flask import Flask
from webmentions_ssg import VERSION, huey
@@ -22,3 +25,25 @@ def test_create_app_exposes_version_in_templates(app: Flask) -> None:
app.update_template_context(context)
assert context["VERSION"] == VERSION
+
+
+def test_importing_views_and_tasks_before_creating_app() -> None:
+ """Module imports alone must never need an initialized Huey backend."""
+ script = """
+from webmentions_ssg import huey
+from webmentions_ssg.tasks.scanner import manual_scan_sources
+from webmentions_ssg.tasks.receiver import verify_webmention
+from webmentions_ssg.tasks.sender import send_webmention
+from webmentions_ssg.views import root_page
+
+assert huey.app is None
+assert huey._huey is None
+assert manual_scan_sources.__name__ == 'manual_scan_sources'
+assert verify_webmention.__name__ == 'verify_webmention'
+assert send_webmention.__name__ == 'send_webmention'
+assert root_page.name == 'root'
+"""
+ result = subprocess.run(
+ [sys.executable, "-c", script], capture_output=True, text=True, check=False
+ )
+ assert result.returncode == 0, result.stderr