aboutsummaryrefslogtreecommitdiff
path: root/tests/test_init.py
diff options
context:
space:
mode:
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