From 52fc66cb5ff19bf0def001ae50acc1b465a0b977 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Thu, 12 Nov 2026 23:34:46 +0100 Subject: 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. --- tests/test_init.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/test_init.py') 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 -- cgit v1.3.1