Remove unused templates for newsletter creation, settings, and submissions; update unsubscribe confirmation link; add tests for email templates API.
This commit is contained in:
43
tests/test_email_templates_api.py
Normal file
43
tests/test_email_templates_api.py
Normal 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
|
||||
Reference in New Issue
Block a user