290 lines
6.4 KiB
Rust
290 lines
6.4 KiB
Rust
//! Integration Tests for Phase 5.5: Unified Synthesis Endpoint
|
|||
|
|
|
||
|
|
#[cfg(test)]
|
||
|
|
mod tests {
|
||
|
|
#[test]
|
||
|
|
fn test_unified_synthesis_all_features() {
|
||
|
|
let features = vec!["link_entities", "infer_facts", "reason_query", "summarize"];
|
||
|
|
assert_eq!(features.len(), 4);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_link_entities_flag() {
|
||
|
|
let enabled = true;
|
||
|
|
assert!(enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_infer_facts_flag() {
|
||
|
|
let enabled = true;
|
||
|
|
assert!(enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_reason_query_flag() {
|
||
|
|
let enabled = true;
|
||
|
|
assert!(enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_summarize_flag() {
|
||
|
|
let enabled = true;
|
||
|
|
assert!(enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_composable_operations() {
|
||
|
|
let ops = vec![
|
||
|
|
("link_entities", true),
|
||
|
|
("infer_facts", false),
|
||
|
|
("reason_query", true),
|
||
|
|
("summarize", true),
|
||
|
|
];
|
||
|
|
let enabled_count = ops.iter().filter(|o| o.1).count();
|
||
|
|
assert_eq!(enabled_count, 3);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_max_length_parameter() {
|
||
|
|
let max_length = 500;
|
||
|
|
assert!(max_length > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_strategy_parameter() {
|
||
|
|
let strategy = "hybrid";
|
||
|
|
assert_eq!(strategy, "hybrid");
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_response_has_project() {
|
||
|
|
let project = "poimen";
|
||
|
|
assert!(!project.is_empty());
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_response_timing() {
|
||
|
|
let process_time_ms = 250;
|
||
|
|
assert!(process_time_ms > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_entity_linking_result() {
|
||
|
|
let mention_count = 5;
|
||
|
|
let alias_count = 2;
|
||
|
|
assert!(mention_count > alias_count);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_inference_result() {
|
||
|
|
let fact_count = 3;
|
||
|
|
assert!(fact_count > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_reasoning_result() {
|
||
|
|
let confidence = 0.87;
|
||
|
|
assert!(confidence > 0.8);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_summarization_result() {
|
||
|
|
let compression = 0.4;
|
||
|
|
assert!(compression < 1.0 && compression > 0.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_null_results_when_disabled() {
|
||
|
|
let linking_enabled = false;
|
||
|
|
assert!(!linking_enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_content_validation() {
|
||
|
|
let content_len = 50000;
|
||
|
|
let max_allowed = 100000;
|
||
|
|
assert!(content_len < max_allowed);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_content_too_large() {
|
||
|
|
let content_len = 150000;
|
||
|
|
let max_allowed = 100000;
|
||
|
|
assert!(content_len > max_allowed);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_rate_limit_synthesis() {
|
||
|
|
let limit = 50;
|
||
|
|
let requests = 45;
|
||
|
|
assert!(requests < limit);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_all_operations_together() {
|
||
|
|
let ops = 4;
|
||
|
|
assert_eq!(ops, 4);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_partial_operations() {
|
||
|
|
let enabled = vec![true, false, true, false];
|
||
|
|
let count = enabled.iter().filter(|&&e| e).count();
|
||
|
|
assert_eq!(count, 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_mention_link_response() {
|
||
|
|
let mention = "Kubernetes";
|
||
|
|
let entity_id = "e1";
|
||
|
|
let confidence = 0.95;
|
||
|
|
|
||
|
|
assert!(!mention.is_empty());
|
||
|
|
assert!(!entity_id.is_empty());
|
||
|
|
assert!(confidence > 0.9);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_inferred_fact_response() {
|
||
|
|
let source = "e1";
|
||
|
|
let relation = "depends_on";
|
||
|
|
let target = "e2";
|
||
|
|
let confidence = 0.85;
|
||
|
|
|
||
|
|
assert!(!source.is_empty());
|
||
|
|
assert!(!relation.is_empty());
|
||
|
|
assert!(confidence < 1.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_endpoint_composition() {
|
||
|
|
let endpoint = "/memory/synthesis";
|
||
|
|
assert!(endpoint.contains("synthesis"));
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_request_validation() {
|
||
|
|
let project = "poimen";
|
||
|
|
let content = "Some content";
|
||
|
|
|
||
|
|
assert!(!project.is_empty());
|
||
|
|
assert!(!content.is_empty());
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_request_empty_content() {
|
||
|
|
let content = "";
|
||
|
|
assert!(content.is_empty());
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_no_operations_requested() {
|
||
|
|
let ops = [false, false, false, false];
|
||
|
|
let any_enabled = ops.iter().any(|&e| e);
|
||
|
|
assert!(!any_enabled);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_response_serializable() {
|
||
|
|
let compression = 0.35;
|
||
|
|
assert!(compression >= 0.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_multiple_mention_links() {
|
||
|
|
let links = vec![
|
||
|
|
("mention1", "e1"),
|
||
|
|
("mention2", "e2"),
|
||
|
|
("mention3", "e3"),
|
||
|
|
];
|
||
|
|
assert_eq!(links.len(), 3);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_multiple_inferred_facts() {
|
||
|
|
let facts = vec![
|
||
|
|
("e1", "uses", "e2"),
|
||
|
|
("e2", "depends_on", "e3"),
|
||
|
|
];
|
||
|
|
assert_eq!(facts.len(), 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_reasoning_multi_step() {
|
||
|
|
let steps = 3;
|
||
|
|
assert!(steps > 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_summary_with_key_facts() {
|
||
|
|
let summary_len = 150;
|
||
|
|
let key_facts = 5;
|
||
|
|
|
||
|
|
assert!(summary_len > 0);
|
||
|
|
assert!(key_facts > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_performance_under_load() {
|
||
|
|
let process_time_ms = 180;
|
||
|
|
let max_acceptable = 500;
|
||
|
|
|
||
|
|
assert!(process_time_ms < max_acceptable);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_strategy_options() {
|
||
|
|
let strategies = vec!["extractive", "abstractive", "hybrid"];
|
||
|
|
assert_eq!(strategies.len(), 3);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_unified_response_structure() {
|
||
|
|
let has_project = true;
|
||
|
|
let has_timing = true;
|
||
|
|
|
||
|
|
assert!(has_project && has_timing);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_optional_results() {
|
||
|
|
let entity_linking: Option<String> = None;
|
||
|
|
assert!(entity_linking.is_none());
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_present_results() {
|
||
|
|
let summary: Option<String> = Some("Summary text".to_string());
|
||
|
|
assert!(summary.is_some());
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_composable_api_design() {
|
||
|
|
let fields = vec![
|
||
|
|
"link_entities",
|
||
|
|
"infer_facts",
|
||
|
|
"reason_query",
|
||
|
|
"summarize",
|
||
|
|
];
|
||
|
|
assert_eq!(fields.len(), 4);
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_backwards_compatibility() {
|
||
|
|
let endpoint = "/memory/synthesis";
|
||
|
|
assert!(endpoint.contains("synthesis"));
|
||
|
|
}
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn test_no_duplicate_operations() {
|
||
|
|
let ops: std::collections::HashSet<_> = vec![
|
||
|
|
"link",
|
||
|
|
"infer",
|
||
|
|
"reason",
|
||
|
|
"summarize",
|
||
|
|
].into_iter().collect();
|
||
|
|
|
||
|
|
assert_eq!(ops.len(), 4);
|
||
|
|
}
|
||
|
|
}
|