Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(composio): add mock tests for profile tools execute

Steven Enamakeldc224dbfdc20
diff --git a/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs b/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs
index df39368f2a..4b0dd63069 100644
--- a/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops_profile_tools_execute_mock_tests.rs
@@ -183,131 +183,6 @@ async fn composio_execute_via_mock_propagates_backend_error() {
assert!(err.contains("rate limited"), "got: {err}");
}
-#[tokio::test]
-async fn composio_list_tools_honours_a_preference_still_in_the_legacy_file() {
- // A workspace upgraded from before the preference moved into the module
- // still has `composio_user_scopes.json`. The module filters the listing by
- // the preference it holds, so that file must be migrated before the call;
- // otherwise its default (`write` on) outranks the user's stored `write=false`.
- let _serialised = module_guard().await;
- let app = Router::new().route(
- "/agent-integrations/composio/tools",
- get(|| async {
- Json(json!({
- "success": true,
- "data": {"tools": [
- {"type":"function","function":{"name":"GMAIL_FETCH_EMAILS"}},
- {"type":"function","function":{"name":"GMAIL_SEND_EMAIL"}}
- ]}
- }))
- }),
- );
- let base = start_mock_backend(app).await;
- let tmp = tempfile::tempdir().unwrap();
- let config = config_with_backend(&tmp, base);
- let legacy: std::collections::BTreeMap<String, crate::integrations::composio::contract::UserScopePref> =
- serde_json::from_value(json!({"gmail": {"read": true, "write": false, "admin": false}}))
- .unwrap();
- crate::integrations::composio::file_store::save(
- &config,
- crate::integrations::composio::file_store::USER_SCOPES_FILE,
- &legacy,
- )
- .await
- .unwrap();
-
- let outcome = composio_list_tools(&config, Some(vec!["gmail".into()]), None)
- .await
- .unwrap();
- assert_eq!(outcome.value.tools.len(), 2);
-}
-
-#[tokio::test]
-async fn composio_list_tools_lets_the_module_apply_the_scope_preference_and_catalog() {
- // The host no longer opts out of the module's scope filter
- // (`apply_user_scopes` defaults on): an admin-scoped action, and one the
- // gmail catalog does not name, never reach the caller.
- let _serialised = module_guard().await;
- let app = Router::new().route(
- "/agent-integrations/composio/tools",
- get(|| async {
- Json(json!({
- "success": true,
- "data": {"tools": [
- {"type":"function","function":{"name":"GMAIL_FETCH_EMAILS"}},
- {"type":"function","function":{"name":"GMAIL_DELETE_MESSAGE"}},
- {"type":"function","function":{"name":"GMAIL_NOT_IN_THE_CATALOG"}}
- ]}
- }))
- }),
- );
- let base = start_mock_backend(app).await;
- let tmp = tempfile::tempdir().unwrap();
- let config = config_with_backend(&tmp, base);
- let outcome = composio_list_tools(&config, Some(vec!["gmail".into()]), None)
- .await
- .unwrap();
- let names: Vec<&str> = outcome
- .value
- .tools
- .iter()
- .map(|tool| tool.function.name.as_str())
- .collect();
- assert_eq!(names, ["GMAIL_FETCH_EMAILS"]);
-}
-
-#[tokio::test]
-async fn composio_execute_via_mock_succeeds_and_logs_elapsed() {
- let _serialised = module_guard().await;
- let app = Router::new().route(
- "/agent-integrations/composio/execute",
- post(|Json(b): Json<Value>| async move {
- Json(json!({
- "success": true,
- "data": {
- "data": {"echo": b["tool"]},
- "successful": true,
- "error": null,
- "costUsd": 0.001
- }
- }))
- }),
- );
- let base = start_mock_backend(app).await;
- let tmp = tempfile::tempdir().unwrap();
- let config = config_with_backend(&tmp, base);
- let outcome = composio_execute(&config, "GMAIL_SEND", Some(json!({"to": "a"})), None)
- .await
- .unwrap();
- assert!(outcome.value.successful);
- assert!(outcome
- .logs
- .iter()
- .any(|l| l.contains("executed GMAIL_SEND")));
-}
-
-#[tokio::test]
-async fn composio_execute_via_mock_propagates_backend_error() {
- let _serialised = module_guard().await;
- let app = Router::new().route(
- "/agent-integrations/composio/execute",
- post(|| async { Json(json!({"success": false, "error": "rate limited"})) }),
- );
- let base = start_mock_backend(app).await;
- let tmp = tempfile::tempdir().unwrap();
- let config = config_with_backend(&tmp, base);
- let err = composio_execute(&config, "ANY_TOOL", None, None)
- .await
- .unwrap_err();
- // The dispatcher (`execute_composio_action`) classifies transport
- // failures and prefixes them with `[composio:error:<class>] …`; ops.rs
- // preserves that prefix so the frontend formatter can parse the class.
- // For an unrecognised tool slug and a 502-shaped envelope the only
- // signal we get is the backend error text, so assert on its contents.
- assert!(err.starts_with("[composio:error:"), "got: {err}");
- assert!(err.contains("rate limited"), "got: {err}");
-}
-
#[tokio::test]
async fn composio_list_tools_honours_a_preference_still_in_the_legacy_file() {
// A workspace upgraded from before the preference moved into the module