47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
import pytest
|
|
from fastapi import status
|
|
|
|
|
|
def test_get_backups(test_client, admin_token):
|
|
response = test_client.get(
|
|
"/admin/db/backups",
|
|
headers={"Authorization": f"Bearer {admin_token}"}
|
|
)
|
|
assert response.status_code == status.HTTP_200_OK
|
|
assert isinstance(response.json(), list)
|
|
|
|
|
|
def test_db_settings_workflow(test_client, admin_token):
|
|
# GET settings
|
|
response = test_client.get(
|
|
"/admin/db/settings",
|
|
headers={"Authorization": f"Bearer {admin_token}"}
|
|
)
|
|
assert response.status_code == status.HTTP_200_OK
|
|
data = response.json()
|
|
assert "retention_count" in data
|
|
|
|
# PATCH settings
|
|
new_settings = {
|
|
"retention_count": 25,
|
|
"schedule_hour": 5,
|
|
"schedule_freq_days": 2
|
|
}
|
|
response = test_client.patch(
|
|
"/admin/db/settings",
|
|
json=new_settings,
|
|
headers={"Authorization": f"Bearer {admin_token}"}
|
|
)
|
|
assert response.status_code == status.HTTP_200_OK
|
|
assert response.json()["retention_count"] == 25
|
|
|
|
|
|
def test_ai_config(test_client, admin_token):
|
|
response = test_client.get(
|
|
"/admin/ai/settings",
|
|
headers={"Authorization": f"Bearer {admin_token}"}
|
|
)
|
|
assert response.status_code == status.HTTP_200_OK
|
|
data = response.json()
|
|
assert "active_provider" in data
|