test(ai): Day 5.3 — 补充 5 个老 Tool 单元测试

- query_vitals: tool_name + schema_has_days_param
- query_lab_reports: tool_name
- query_appointments: tool_name
- query_medications: tool_name
- search_medical_knowledge: tool_name + schema_requires_query
This commit is contained in:
iven
2026-05-19 11:15:22 +08:00
parent bcff978ea0
commit b03ea47fed
5 changed files with 74 additions and 0 deletions

View File

@@ -66,3 +66,14 @@ impl AgentTool for QueryAppointmentsTool {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_name() {
let tool = QueryAppointmentsTool;
assert_eq!(tool.name(), "query_patient_appointments");
}
}

View File

@@ -83,3 +83,14 @@ impl AgentTool for QueryLabReportsTool {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_name() {
let tool = QueryLabReportsTool;
assert_eq!(tool.name(), "query_patient_lab_reports");
}
}

View File

@@ -63,3 +63,14 @@ impl AgentTool for QueryMedicationsTool {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_name() {
let tool = QueryMedicationsTool;
assert_eq!(tool.name(), "query_patient_medications");
}
}

View File

@@ -94,3 +94,21 @@ impl AgentTool for QueryPatientVitalsTool {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_name() {
let tool = QueryPatientVitalsTool;
assert_eq!(tool.name(), "query_patient_vitals");
}
#[test]
fn schema_has_days_param() {
let tool = QueryPatientVitalsTool;
let schema = tool.parameters_schema();
assert!(schema["properties"]["days"].is_object());
}
}

View File

@@ -110,3 +110,26 @@ impl AgentTool for SearchMedicalKnowledgeTool {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn tool_name() {
let tool = SearchMedicalKnowledgeTool;
assert_eq!(tool.name(), "search_medical_knowledge");
}
#[test]
fn schema_requires_query() {
let tool = SearchMedicalKnowledgeTool;
let schema = tool.parameters_schema();
assert!(
schema["required"]
.as_array()
.unwrap()
.contains(&serde_json::json!("query"))
);
}
}