初始化测试通过
This commit is contained in:
@@ -10,8 +10,12 @@ from __future__ import annotations
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
import logging
|
||||
|
||||
from db.connection import get_conn
|
||||
from util.logging_config import get_skill_logger, setup_skill_logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# 业务常量(不暴露给宿主,技能自定)
|
||||
STATUS_PENDING = "pending"
|
||||
@@ -59,8 +63,10 @@ def add_todo(
|
||||
"""新增一条待办。领域校验:标题非空、优先级合法。"""
|
||||
title = (title or "").strip()
|
||||
if not title:
|
||||
logger.warning("标题不能为空")
|
||||
raise ValueError("标题不能为空")
|
||||
if priority not in VALID_PRIORITY:
|
||||
logger.warning(f"优先级不合法,可选:{sorted(VALID_PRIORITY)}")
|
||||
raise ValueError(f"优先级不合法,可选:{sorted(VALID_PRIORITY)}")
|
||||
now = _now()
|
||||
conn = get_conn()
|
||||
@@ -84,6 +90,7 @@ def list_todos(*, status: Optional[str] = None, limit: int = 100) -> list[Todo]:
|
||||
params: list = []
|
||||
if status:
|
||||
if status not in VALID_STATUS:
|
||||
logger.warning(f"状态不合法,可选:{sorted(VALID_STATUS)}")
|
||||
raise ValueError(f"状态不合法,可选:{sorted(VALID_STATUS)}")
|
||||
sql += " WHERE status = ?"
|
||||
params.append(status)
|
||||
@@ -118,8 +125,10 @@ def mark_done(todo_id: int) -> Todo:
|
||||
"""标记一条待办为完成。"""
|
||||
todo = get_todo(todo_id)
|
||||
if not todo:
|
||||
logger.warning(f"待办 {todo_id} 不存在")
|
||||
raise ValueError(f"待办 {todo_id} 不存在")
|
||||
if todo.status == STATUS_DONE:
|
||||
logger.warning(f"待办 {todo_id} 已是完成状态")
|
||||
raise ValueError(f"待办 {todo_id} 已是完成状态")
|
||||
now = _now()
|
||||
conn = get_conn()
|
||||
|
||||
Reference in New Issue
Block a user