Initial commit: TradeMate 外贸小助手 MVP
项目结构: - backend/ Python FastAPI 后端 - uni-app/ uni-app跨端前端 - docs/ 设计文档 - docker-compose.yml Docker编排 - nginx/scripts/systemd 运维配置 已完成功能: - 用户认证 (JWT) - 智能翻译 + 回复建议 - 营销素材生成 - 客户管理 + 沉默检测 - 报价单管理 - 产品库管理 - 汇率换算 - 推送通知 (uni-push) - WhatsApp Webhook框架 - Celery定时任务
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import pytest
|
||||
from app.core.exceptions import (
|
||||
TradeMateException,
|
||||
NotFoundError,
|
||||
UnauthorizedError,
|
||||
ForbiddenError,
|
||||
QuotaExceededError,
|
||||
TierRestrictionError,
|
||||
)
|
||||
|
||||
|
||||
class TestExceptions:
|
||||
def test_trade_mate_exception(self):
|
||||
exc = TradeMateException(400, "Bad Request", "Details")
|
||||
assert exc.code == 400
|
||||
assert exc.message == "Bad Request"
|
||||
assert exc.detail == "Details"
|
||||
|
||||
def test_not_found_error(self):
|
||||
exc = NotFoundError("User")
|
||||
assert exc.code == 404
|
||||
assert "User" in exc.message
|
||||
assert "not found" in exc.message
|
||||
|
||||
def test_unauthorized_error(self):
|
||||
exc = UnauthorizedError()
|
||||
assert exc.code == 401
|
||||
assert exc.message == "Unauthorized"
|
||||
|
||||
def test_forbidden_error(self):
|
||||
exc = ForbiddenError()
|
||||
assert exc.code == 403
|
||||
assert exc.message == "Forbidden"
|
||||
|
||||
def test_quota_exceeded_error(self):
|
||||
exc = QuotaExceededError("translation")
|
||||
assert exc.code == 429
|
||||
assert "Quota exceeded" in exc.message
|
||||
assert "translation" in exc.detail
|
||||
|
||||
def test_tier_restriction_error(self):
|
||||
exc = TierRestrictionError("Advanced Feature", "Pro")
|
||||
assert exc.code == 402
|
||||
assert "Upgrade required" in exc.message
|
||||
assert "Pro" in exc.detail
|
||||
Reference in New Issue
Block a user