Removed an old run configuration, added a new coverage XML report, and updated multiple source files including main.py, middleware, models, routers, services, tests, and utility modules. Also updated pyproject.toml and the lock file. These changes likely include code improvements, test coverage updates, and dependency adjustments.
35 lines
1015 B
Python
35 lines
1015 B
Python
from fastapi.testclient import TestClient
|
|
|
|
from main import app
|
|
|
|
client = TestClient(app)
|
|
|
|
def is_valid_instance_id(instance_id):
|
|
"""Check if a string is a valid UUID4."""
|
|
|
|
import uuid
|
|
|
|
try:
|
|
uuid.UUID(instance_id, version=4)
|
|
except (ValueError, TypeError):
|
|
assert False, f"instance_id is not a valid UUID4: {instance_id}"
|
|
|
|
def test_read_main():
|
|
from utils.conf.appmeta import BackendVersion
|
|
|
|
response = client.get("/api/site/ping")
|
|
json_response = response.json()
|
|
|
|
assert response.status_code == 200
|
|
assert 'instance_id' in json_response
|
|
is_valid_instance_id(json_response['instance_id'])
|
|
|
|
response = client.get("/api/site/config")
|
|
json_response = response.json()
|
|
|
|
assert response.status_code == 200
|
|
assert json_response['code'] == 0
|
|
assert json_response['data'] is not None
|
|
assert json_response['msg'] is None
|
|
assert 'instance_id' in json_response
|
|
is_valid_instance_id(json_response['instance_id']) |