use serde_json::{json, Value};
pub const TEST_ENTITY_KEY: &str = "qr-code";
pub const TEST_ENTITY_KEY_ALT: &str = "barcode";
pub const TEST_LOCALE_FR: &str = "fr-FR";
pub const TEST_LOCALE_EN: &str = "en-US";
pub const TEST_LOCALE_DE: &str = "de-DE";
pub const TEST_LOCALE_ES: &str = "es-MX";
pub const TEST_LOCALE_JA: &str = "ja-JP";
pub const TEST_LOCALE_ZH: &str = "zh-CN";
pub const TEST_LOCALES: &[&str] = &[
TEST_LOCALE_FR,
TEST_LOCALE_EN,
TEST_LOCALE_DE,
TEST_LOCALE_ES,
TEST_LOCALE_JA,
TEST_LOCALE_ZH,
];
pub const TEST_MCP_SERVER: &str = "novanet";
pub const TEST_MCP_SERVER_MOCK: &str = "mock";
pub const TEST_TOOL_DESCRIBE: &str = "novanet_describe";
pub const TEST_TOOL_GENERATE: &str = "novanet_generate";
pub const TEST_TOOL_TRAVERSE: &str = "novanet_traverse";
pub const TEST_TOOL_SEARCH: &str = "novanet_search";
pub const TEST_TOOL_ASSEMBLE: &str = "novanet_assemble";
pub const TEST_WORKFLOW_MINIMAL: &str = r#"
schema: nika/workflow@0.5
workflow: test-workflow
provider: mock
tasks:
- id: task1
infer: "Hello world"
"#;
pub const TEST_WORKFLOW_WITH_MCP: &str = r#"
schema: nika/workflow@0.5
workflow: test-mcp-workflow
provider: mock
mcp:
novanet:
command: "echo mock"
tasks:
- id: describe
invoke:
server: novanet
tool: novanet_describe
params:
entity: "qr-code"
"#;
pub fn entity_params(entity: &str) -> Value {
json!({ "entity": entity })
}
pub fn entity_locale_params(entity: &str, locale: &str) -> Value {
json!({
"entity": entity,
"locale": locale
})
}
pub fn describe_params() -> Value {
entity_params(TEST_ENTITY_KEY)
}
pub fn generate_params() -> Value {
entity_locale_params(TEST_ENTITY_KEY, TEST_LOCALE_FR)
}
pub fn traverse_params(start_key: &str, arc_kinds: &[&str]) -> Value {
json!({
"start_key": start_key,
"arc_kinds": arc_kinds,
"direction": "outgoing"
})
}
pub const TEST_TASK_ID: &str = "test-task-1";
pub const TEST_TASK_ID_ALT: &str = "test-task-2";
pub const TEST_TASK_PARENT: &str = "parent-task";
pub const TEST_TASK_CHILD: &str = "child-task";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_entity_params() {
let params = entity_params(TEST_ENTITY_KEY);
assert_eq!(params["entity"], TEST_ENTITY_KEY);
}
#[test]
fn test_entity_locale_params() {
let params = entity_locale_params(TEST_ENTITY_KEY, TEST_LOCALE_FR);
assert_eq!(params["entity"], TEST_ENTITY_KEY);
assert_eq!(params["locale"], TEST_LOCALE_FR);
}
#[test]
fn test_traverse_params() {
let params = traverse_params(TEST_ENTITY_KEY, &["HAS_NATIVE"]);
assert_eq!(params["start_key"], TEST_ENTITY_KEY);
assert!(params["arc_kinds"]
.as_array()
.unwrap()
.contains(&json!("HAS_NATIVE")));
}
#[test]
fn test_locales_array() {
assert_eq!(TEST_LOCALES.len(), 6);
assert!(TEST_LOCALES.contains(&TEST_LOCALE_FR));
assert!(TEST_LOCALES.contains(&TEST_LOCALE_EN));
}
}