blob: 44375de70d30284e4ab91fe02f69145457c6d6c8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
#
# 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 "webmentions" 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 webmentions_bp
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 webmentions_bp.name == 'webmentions'
"""
result = subprocess.run(
[sys.executable, "-c", script], capture_output=True, text=True, check=False
)
assert result.returncode == 0, result.stderr
|