Remove unused templates for newsletter creation, settings, and submissions; update unsubscribe confirmation link; add tests for email templates API.
All checks were successful
CI / test (3.11) (pull_request) Successful in 1m59s
CI / build-image (pull_request) Successful in 2m43s

This commit is contained in:
2025-11-06 11:10:10 +01:00
parent 3a11b00fd5
commit c1e3ce185f
26 changed files with 1921 additions and 1732 deletions

View File

@@ -0,0 +1,43 @@
import importlib
import pytest
server_app_module = importlib.import_module("server.app")
app = server_app_module.app
@pytest.fixture
def client():
with app.test_client() as client:
yield client
def test_get_settings_returns_dict(client):
# Login as admin first
client.post('/auth/login', data={'username': 'admin', 'password': 'admin'})
resp = client.get('/admin/api/settings')
assert resp.status_code == 200
body = resp.get_json()
assert body['status'] == 'ok'
assert isinstance(body.get('settings'), dict)
def test_update_and_get_newsletter_template(client):
key = 'newsletter_confirmation_template'
sample = '<p>Thanks for subscribing, {{email}}</p>'
# Update via PUT
# Login as admin first
client.post('/auth/login', data={'username': 'admin', 'password': 'admin'})
resp = client.put(f'/admin/api/settings/{key}', json={'value': sample})
assert resp.status_code == 200
body = resp.get_json()
assert body['status'] == 'ok'
# Retrieve via GET and ensure the value is present
resp = client.get('/admin/api/settings')
assert resp.status_code == 200
body = resp.get_json()
assert body['status'] == 'ok'
settings = body.get('settings') or {}
assert settings.get(key) == sample