feat(tests): fix warning and correct path

This commit is contained in:
2026-05-05 11:16:48 +08:00
parent 3ab845798d
commit 344cfe4947
4 changed files with 14 additions and 27 deletions
+3 -4
View File
@@ -1,6 +1,6 @@
from datetime import datetime from datetime import datetime
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, field_validator from pydantic import BaseModel, ConfigDict, Field, field_validator
class TaskBase(BaseModel): class TaskBase(BaseModel):
@@ -132,6 +132,8 @@ class TaskUpdate(BaseModel):
class TaskResponse(TaskBase): class TaskResponse(TaskBase):
"""打卡任务响应 Schema""" """打卡任务响应 Schema"""
model_config = ConfigDict(from_attributes=True)
id: int id: int
user_id: int user_id: int
created_at: datetime created_at: datetime
@@ -145,6 +147,3 @@ class TaskResponse(TaskBase):
last_check_in_time: Optional[datetime] = Field(None, description="最后一次打卡时间") last_check_in_time: Optional[datetime] = Field(None, description="最后一次打卡时间")
last_check_in_status: Optional[str] = Field(None, description="最后一次打卡状态") last_check_in_status: Optional[str] = Field(None, description="最后一次打卡状态")
thread_id: Optional[str] = Field(None, description="接龙 ID(从 payload_config 中提取)") thread_id: Optional[str] = Field(None, description="接龙 ID(从 payload_config 中提取)")
class Config:
from_attributes = True
+4 -8
View File
@@ -1,6 +1,6 @@
from datetime import datetime from datetime import datetime
from typing import Optional, Dict, Any, List, Union from typing import Optional, Dict, Any, List, Union
from pydantic import BaseModel, Field, field_validator from pydantic import BaseModel, ConfigDict, Field, field_validator
import json import json
@@ -43,10 +43,7 @@ class FieldConfigItem(BaseModel):
class FieldConfigValues(BaseModel): class FieldConfigValues(BaseModel):
"""Values 字段的嵌套配置(如 location, temperature 等)""" """Values 字段的嵌套配置(如 location, temperature 等)"""
pass model_config = ConfigDict(extra="allow")
class Config:
extra = "allow" # 允许任意字段
class FieldConfig(BaseModel): class FieldConfig(BaseModel):
@@ -128,6 +125,8 @@ class TemplateUpdate(BaseModel):
class TemplateResponse(BaseModel): class TemplateResponse(BaseModel):
"""模板响应 Schema""" """模板响应 Schema"""
model_config = ConfigDict(from_attributes=True)
id: int id: int
name: str name: str
description: Optional[str] description: Optional[str]
@@ -137,9 +136,6 @@ class TemplateResponse(BaseModel):
created_at: datetime created_at: datetime
updated_at: Optional[datetime] updated_at: Optional[datetime]
class Config:
from_attributes = True
class TaskFromTemplateRequest(BaseModel): class TaskFromTemplateRequest(BaseModel):
"""从模板创建任务的请求 Schema""" """从模板创建任务的请求 Schema"""
+3 -4
View File
@@ -1,6 +1,6 @@
from datetime import datetime from datetime import datetime
from typing import Optional from typing import Optional
from pydantic import BaseModel, Field, EmailStr from pydantic import BaseModel, ConfigDict, EmailStr, Field
class UserBase(BaseModel): class UserBase(BaseModel):
@@ -45,6 +45,8 @@ class UserUpdateProfile(BaseModel):
class UserResponse(BaseModel): class UserResponse(BaseModel):
"""用户响应 Schema""" """用户响应 Schema"""
model_config = ConfigDict(from_attributes=True)
id: int id: int
alias: str alias: str
role: str role: str
@@ -55,9 +57,6 @@ class UserResponse(BaseModel):
created_at: datetime created_at: datetime
updated_at: Optional[datetime] = None updated_at: Optional[datetime] = None
class Config:
from_attributes = True
class UserWithToken(UserResponse): class UserWithToken(UserResponse):
"""带 Token 的用户响应 Schema""" """带 Token 的用户响应 Schema"""
@@ -3,11 +3,11 @@ from __future__ import annotations
from pathlib import Path from pathlib import Path
FRONTEND_ROOT = Path(__file__).resolve().parents[1] / "apps" / "new-frontend" FRONTEND_ROOT = Path(__file__).resolve().parents[1] / "apps" / "frontend"
SRC_ROOT = FRONTEND_ROOT / "src" SRC_ROOT = FRONTEND_ROOT / "src"
def test_new_frontend_has_business_app_structure() -> None: def test_frontend_has_business_app_structure() -> None:
expected_files = [ expected_files = [
"api/client.ts", "api/client.ts",
"api/index.ts", "api/index.ts",
@@ -37,7 +37,7 @@ def test_new_frontend_has_business_app_structure() -> None:
assert missing == [] assert missing == []
def test_new_frontend_routes_cover_user_and_admin_workflows() -> None: def test_frontend_routes_cover_user_and_admin_workflows() -> None:
router = (SRC_ROOT / "app" / "router.ts").read_text(encoding="utf-8") router = (SRC_ROOT / "app" / "router.ts").read_text(encoding="utf-8")
for path in [ for path in [
@@ -57,15 +57,8 @@ def test_new_frontend_routes_cover_user_and_admin_workflows() -> None:
assert path in router assert path in router
def test_new_frontend_replaces_starter_component() -> None: def test_frontend_replaces_starter_component() -> None:
app = (SRC_ROOT / "App.vue").read_text(encoding="utf-8") app = (SRC_ROOT / "App.vue").read_text(encoding="utf-8")
assert "HelloWorld" not in app assert "HelloWorld" not in app
assert not (SRC_ROOT / "components" / "HelloWorld.vue").exists() assert not (SRC_ROOT / "components" / "HelloWorld.vue").exists()
def test_theme_switch_is_icon_only_but_accessible() -> None:
layout = (SRC_ROOT / "components" / "AppLayout.vue").read_text(encoding="utf-8")
assert "切换主题,当前${themeLabel}" in layout
assert "{{ themeLabel }}" not in layout