# SPDX-FileCopyrightText: 2026 Dennis Fink # # SPDX-License-Identifier: BSD-3-Clause """Test application initialization and its public integrations.""" import subprocess import sys from flask import Flask from webmentions_ssg import VERSION, huey from webmentions_ssg.net import is_http_url def test_create_app_registers_blueprint_and_extensions(app: Flask) -> None: assert "root" in app.blueprints assert app.extensions["huey"] is huey assert app.jinja_env.filters["is_http_url"] is is_http_url def test_create_app_exposes_version_in_templates(app: Flask) -> None: with app.test_request_context(): context: dict[str, str] = {} app.update_template_context(context) assert context["VERSION"] == VERSION def test_importing_views_and_tasks_before_creating_app() -> None: """Verify that imports do not 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