Added a theme selector
This commit is contained in:
@@ -62,9 +62,25 @@ def test_configuration_requires_authentication_and_admin_role():
|
||||
assert client.get('/api/admin/smtp', headers=login_headers('bob')).status_code == 403
|
||||
|
||||
|
||||
def test_admin_can_select_multiple_themes():
|
||||
headers = login_headers()
|
||||
response = client.put('/api/admin/themes', headers=headers, json={
|
||||
'themes': ['plain-day', 'plain-night', 'latte', 'frappe', 'macchiato', 'mocha', 'dracula', 'nord', 'solarized'],
|
||||
})
|
||||
assert response.status_code == 200
|
||||
assert response.json()['enabled'] == ['plain-day', 'plain-night', 'latte', 'frappe', 'macchiato', 'mocha', 'dracula', 'nord', 'solarized']
|
||||
public_response = client.get('/api/public/themes')
|
||||
assert public_response.status_code == 200
|
||||
assert [theme['id'] for theme in public_response.json()] == response.json()['enabled']
|
||||
|
||||
assert client.put('/api/admin/themes', headers=headers, json={'themes': []}).status_code == 422
|
||||
|
||||
|
||||
def test_admin_can_save_and_validate_smtp_settings():
|
||||
headers = login_headers()
|
||||
original = get_smtp_settings()
|
||||
with get_connection() as conn:
|
||||
original_row = conn.execute('SELECT value FROM app_settings WHERE name = ?', ('smtp',)).fetchone()
|
||||
response = client.put('/api/admin/smtp', headers=headers, json={
|
||||
'smtp_host': 'smtp.example.com',
|
||||
'smtp_port': 587,
|
||||
@@ -97,7 +113,18 @@ def test_admin_can_save_and_validate_smtp_settings():
|
||||
'smtp_use_tls': False,
|
||||
})
|
||||
|
||||
client.put('/api/admin/smtp', headers=headers, json=original)
|
||||
with get_connection() as conn:
|
||||
if original_row is None:
|
||||
conn.execute('DELETE FROM app_settings WHERE name = ?', ('smtp',))
|
||||
else:
|
||||
conn.execute(
|
||||
'UPDATE app_settings SET value = ?, updated_at = CURRENT_TIMESTAMP WHERE name = ?',
|
||||
(original_row['value'], 'smtp'),
|
||||
)
|
||||
conn.commit()
|
||||
with get_connection() as conn:
|
||||
conn.execute('DELETE FROM app_settings WHERE name = ?', ('admin_smtp_mail_rate',))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def test_admin_reports_smtp_validation_errors():
|
||||
|
||||
Reference in New Issue
Block a user