51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pathlib import Path
|
||
|
|
import sys
|
||
|
|
|
||
|
|
CURRENT_DIR = Path(__file__).resolve().parent
|
||
|
|
PROJECT_ROOT = CURRENT_DIR.parent.parent
|
||
|
|
if str(PROJECT_ROOT) not in sys.path:
|
||
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
||
|
|
|
||
|
|
from backend.app.services.auth_service import auth_service
|
||
|
|
from backend.app.services.export_service import export_service
|
||
|
|
from backend.app.services.storage_service import storage_service
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> None:
|
||
|
|
checks: list[tuple[str, bool, str]] = []
|
||
|
|
|
||
|
|
export_meta = export_service.build_performance_export(
|
||
|
|
{
|
||
|
|
"stat_type": "month",
|
||
|
|
"list": [
|
||
|
|
{
|
||
|
|
"stat_period": "2026-05",
|
||
|
|
"order_count": 1,
|
||
|
|
"order_amount": 100.0,
|
||
|
|
"commission_amount": 10.0,
|
||
|
|
"category_amounts": [{"category_id": 1, "category_name": "演示分类", "amount": 100.0}],
|
||
|
|
}
|
||
|
|
],
|
||
|
|
},
|
||
|
|
"xlsx",
|
||
|
|
)
|
||
|
|
checks.append(("报表导出", Path(export_meta["file_path"]).exists(), export_meta["file_name"]))
|
||
|
|
|
||
|
|
upload_meta = storage_service.create_upload_token("smoke", 1, "demo.png", 1024)
|
||
|
|
checks.append(("OSS 上传签名", upload_meta["upload_url"].startswith("https://"), upload_meta["object_key"]))
|
||
|
|
|
||
|
|
checks.append(("token 黑名单文件目录", auth_service.token_store_path.parent.exists(), str(auth_service.token_store_path)))
|
||
|
|
|
||
|
|
failed = [item for item in checks if not item[1]]
|
||
|
|
for name, ok, detail in checks:
|
||
|
|
print(f"[{'PASS' if ok else 'FAIL'}] {name}: {detail}")
|
||
|
|
|
||
|
|
if failed:
|
||
|
|
raise SystemExit(1)
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|