You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
csg-server/tests/test_api_module_common.py

36 lines
1.1 KiB
Python

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
模块接口测试 —— module_common公共模块
每个接口一个测试用例,验证路由存在且返回码正确。
"""
from conftest import assert_route
from fastapi.testclient import TestClient
class TestHealth:
"""健康检查接口。"""
def test_health_check(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/common/health", expected_status=200)
def test_health_ready(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/common/health/ready", expected_status=200)
def test_health_live(self, test_client: TestClient) -> None:
assert_route(test_client, "GET", "/common/health/live", expected_status=200)
class TestFile:
"""文件管理接口。"""
def test_upload_file(self, test_client: TestClient) -> None:
assert_route(test_client, "POST", "/common/file/upload")
def test_download_file(self, test_client: TestClient) -> None:
assert_route(
test_client,
"POST",
"/common/file/download",
json={"file_path": "test.txt", "delete": False},
)