Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | """Tests for auto_upload_download_files feature in Composio SDK. |
| 2 | |
| 3 | This module tests the auto_upload_download_files configuration option that controls |
| 4 | automatic file upload and download behavior during tool execution. |
| 5 | """ |
| 6 | |
| 7 | from unittest.mock import Mock, patch |
| 8 | |
| 9 | import pytest |
| 10 | |
| 11 | from composio.client.types import Tool, tool_list_response |
| 12 | from composio.core.models.base import allow_tracking |
| 13 | from composio.core.models.tools import Tools |
| 14 | |
| 15 | from tests.conftest import mock_http_client |
| 16 | |
| 17 | |
| 18 | @pytest.fixture(autouse=True) |
| 19 | def disable_telemetry(): |
| 20 | """Disable telemetry for all tests to prevent thread issues.""" |
| 21 | token = allow_tracking.set(False) |
| 22 | yield |
| 23 | allow_tracking.reset(token) |
| 24 | |
| 25 | |
| 26 | @pytest.fixture |
| 27 | def mock_client(): |
| 28 | """Create a mock HTTP client.""" |
| 29 | return mock_http_client() |
| 30 | |
| 31 | |
| 32 | @pytest.fixture |
| 33 | def mock_provider(): |
| 34 | """Create a mock provider.""" |
| 35 | provider = Mock() |
| 36 | provider.name = "test_provider" |
| 37 | return provider |
| 38 | |
| 39 | |
| 40 | def create_mock_tool( |
| 41 | slug: str, |
| 42 | toolkit_slug: str, |
| 43 | input_parameters: dict | None = None, |
| 44 | output_parameters: dict | None = None, |
| 45 | ) -> Tool: |
| 46 | """Create a mock tool for testing.""" |
| 47 | return Tool( |
| 48 | name=f"Test {slug}", |
| 49 | slug=slug, |
| 50 | description="Test tool", |
| 51 | input_parameters=input_parameters or {"type": "object", "properties": {}}, |
| 52 | output_parameters=output_parameters or {"type": "object", "properties": {}}, |
| 53 | available_versions=["v1.0.0"], |
| 54 | version="v1.0.0", |
| 55 | scopes=[], |
| 56 | toolkit=tool_list_response.ItemToolkit( |
| 57 | name=toolkit_slug.title(), slug=toolkit_slug, logo="" |
| 58 | ), |
| 59 | deprecated=tool_list_response.ItemDeprecated( |
| 60 | available_versions=["v1.0.0"], |
| 61 | displayName=f"Test {slug}", |
| 62 | version="v1.0.0", |
| 63 | toolkit=tool_list_response.ItemDeprecatedToolkit(logo=""), |
| 64 | is_deprecated=False, |
| 65 | ), |
| 66 | is_deprecated=False, |
| 67 | no_auth=False, |
| 68 | tags=[], |
| 69 | ) |
| 70 | |
| 71 | |
| 72 | class TestAutoUploadDownloadFilesEnabled: |
| 73 | """Test cases when auto_upload_download_files is enabled.""" |
| 74 | |
| 75 | def test_get_processes_schema_for_file_uploadable(self, mock_client, mock_provider): |
| 76 | """Test that _get processes schema when auto_upload_download_files is True.""" |
| 77 | tools = Tools( |
| 78 | client=mock_client, |
| 79 | provider=mock_provider, |
| 80 | dangerously_allow_auto_upload_download_files=True, |
| 81 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 82 | ) |
| 83 | |
| 84 | # Create tool with file_uploadable field |
| 85 | mock_tool = create_mock_tool( |
| 86 | slug="TEST_TOOL", |
| 87 | toolkit_slug="test_toolkit", |
| 88 | input_parameters={ |
| 89 | "type": "object", |
| 90 | "properties": { |
| 91 | "file": { |
| 92 | "type": "string", |
| 93 | "file_uploadable": True, |
| 94 | "description": "Upload a file", |
| 95 | }, |
| 96 | "text": {"type": "string"}, |
| 97 | }, |
| 98 | }, |
| 99 | ) |
| 100 | |
| 101 | # Mock client.tools.list |
| 102 | mock_client.tools.list.return_value = Mock(items=[mock_tool]) |
| 103 | |
| 104 | # Mock provider.wrap_tools |
| 105 | mock_provider.wrap_tools = Mock(return_value=[]) |
| 106 | |
| 107 | # Get tools |
| 108 | tools._get(user_id="test-user", tools=["TEST_TOOL"]) |
| 109 | |
| 110 | # Verify schema was processed (format: "path" added to file_uploadable field) |
| 111 | wrap_tools_call = mock_provider.wrap_tools.call_args |
| 112 | processed_tools = wrap_tools_call[1]["tools"] |
| 113 | file_param = processed_tools[0].input_parameters["properties"]["file"] |
| 114 | |
| 115 | # Check that file_uploadable schema was converted to path format |
| 116 | assert file_param.get("format") == "path" |
| 117 | assert file_param.get("type") == "string" |
| 118 | |
| 119 | def test_execute_calls_substitute_file_uploads(self, mock_client, mock_provider): |
| 120 | """Test that execute calls substitute_file_uploads when enabled.""" |
| 121 | tools = Tools( |
| 122 | client=mock_client, |
| 123 | provider=mock_provider, |
| 124 | dangerously_allow_auto_upload_download_files=True, |
| 125 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 126 | ) |
| 127 | |
| 128 | mock_tool = create_mock_tool( |
| 129 | slug="TEST_TOOL", |
| 130 | toolkit_slug="test_toolkit", |
| 131 | input_parameters={ |
| 132 | "type": "object", |
| 133 | "properties": { |
| 134 | "file": {"type": "string", "file_uploadable": True}, |
| 135 | }, |
| 136 | }, |
| 137 | output_parameters={ |
| 138 | "type": "object", |
| 139 | "properties": {}, |
| 140 | }, |
| 141 | ) |
| 142 | |
| 143 | with patch.object( |
| 144 | tools, "get_raw_composio_tool_by_slug", return_value=mock_tool |
| 145 | ): |
| 146 | mock_execute_response = Mock() |
| 147 | mock_execute_response.model_dump.return_value = { |
| 148 | "data": {"result": "success"}, |
| 149 | "error": None, |
| 150 | "successful": True, |
| 151 | } |
| 152 | mock_client.tools.execute.return_value = mock_execute_response |
| 153 | |
| 154 | # Patch both substitute methods to verify substitute_file_uploads is called |
| 155 | with ( |
| 156 | patch.object( |
| 157 | tools._file_helper, "substitute_file_uploads" |
| 158 | ) as mock_upload, |
| 159 | patch.object( |
| 160 | tools._file_helper, "substitute_file_downloads" |
| 161 | ) as mock_download, |
| 162 | ): |
| 163 | mock_upload.return_value = {"file": "processed_path"} |
| 164 | mock_download.return_value = { |
| 165 | "data": {"result": "success"}, |
| 166 | "error": None, |
| 167 | "successful": True, |
| 168 | } |
| 169 | |
| 170 | tools.execute( |
| 171 | slug="TEST_TOOL", |
| 172 | arguments={"file": "/path/to/file.txt"}, |
| 173 | dangerously_skip_version_check=True, |
| 174 | ) |
| 175 | |
| 176 | mock_upload.assert_called_once() |
| 177 | |
| 178 | def test_execute_runs_substitute_before_before_execute( |
| 179 | self, mock_client, mock_provider |
| 180 | ): |
| 181 | """File substitution runs before before_execute modifiers (same order as TypeScript).""" |
| 182 | from composio.core.models._modifiers import Modifier |
| 183 | |
| 184 | tools = Tools( |
| 185 | client=mock_client, |
| 186 | provider=mock_provider, |
| 187 | dangerously_allow_auto_upload_download_files=True, |
| 188 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 189 | ) |
| 190 | |
| 191 | mock_tool = create_mock_tool( |
| 192 | slug="TEST_TOOL", |
| 193 | toolkit_slug="test_toolkit", |
| 194 | input_parameters={ |
| 195 | "type": "object", |
| 196 | "properties": { |
| 197 | "file": {"type": "string", "file_uploadable": True}, |
| 198 | }, |
| 199 | }, |
| 200 | output_parameters={"type": "object", "properties": {}}, |
| 201 | ) |
| 202 | tools._tool_schemas["TEST_TOOL"] = mock_tool |
| 203 | |
| 204 | seen_in_modifier: list = [] |
| 205 | |
| 206 | def before_modifier(tool: str, toolkit: str, params): # type: ignore[no-untyped-def] |
| 207 | seen_in_modifier.append(dict(params["arguments"])) |
| 208 | return params |
| 209 | |
| 210 | modifiers = [ |
| 211 | Modifier( |
| 212 | modifier=before_modifier, type_="before_execute", tools=[], toolkits=[] |
| 213 | ), |
| 214 | ] |
| 215 | |
| 216 | with patch.object( |
| 217 | tools._file_helper, |
| 218 | "substitute_file_uploads", |
| 219 | return_value={"file": "after_substitute"}, |
| 220 | ) as mock_sub: |
| 221 | mock_execute_response = Mock() |
| 222 | mock_execute_response.model_dump.return_value = { |
| 223 | "data": {}, |
| 224 | "error": None, |
| 225 | "successful": True, |
| 226 | } |
| 227 | mock_client.tools.execute.return_value = mock_execute_response |
| 228 | |
| 229 | with patch.object( |
| 230 | tools, "get_raw_composio_tool_by_slug", return_value=mock_tool |
| 231 | ): |
| 232 | tools.execute( |
| 233 | slug="TEST_TOOL", |
| 234 | arguments={"file": "/tmp/x"}, |
| 235 | modifiers=modifiers, |
| 236 | dangerously_skip_version_check=True, |
| 237 | ) |
| 238 | |
| 239 | mock_sub.assert_called_once() |
| 240 | assert len(seen_in_modifier) == 1 |
| 241 | assert seen_in_modifier[0] == {"file": "after_substitute"} |
| 242 | |
| 243 | def test_execute_calls_substitute_file_downloads(self, mock_client, mock_provider): |
| 244 | """Test that execute calls substitute_file_downloads when enabled.""" |
| 245 | tools = Tools( |
| 246 | client=mock_client, |
| 247 | provider=mock_provider, |
| 248 | dangerously_allow_auto_upload_download_files=True, |
| 249 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 250 | ) |
| 251 | |
| 252 | mock_tool = create_mock_tool( |
| 253 | slug="TEST_TOOL", |
| 254 | toolkit_slug="test_toolkit", |
| 255 | input_parameters={ |
| 256 | "type": "object", |
| 257 | "properties": {}, |
| 258 | }, |
| 259 | output_parameters={ |
| 260 | "type": "object", |
| 261 | "properties": { |
| 262 | "file": {"type": "object", "file_downloadable": True}, |
| 263 | }, |
| 264 | }, |
| 265 | ) |
| 266 | |
| 267 | with patch.object( |
| 268 | tools, "get_raw_composio_tool_by_slug", return_value=mock_tool |
| 269 | ): |
| 270 | mock_execute_response = Mock() |
| 271 | mock_execute_response.model_dump.return_value = { |
| 272 | "data": { |
| 273 | "file": { |
| 274 | "name": "result.txt", |
| 275 | "mimetype": "text/plain", |
| 276 | "s3url": "https://s3.example.com/result.txt", |
| 277 | } |
| 278 | }, |
| 279 | "error": None, |
| 280 | "successful": True, |
| 281 | } |
| 282 | mock_client.tools.execute.return_value = mock_execute_response |
| 283 | |
| 284 | # Patch both substitute methods to verify substitute_file_downloads is called |
| 285 | with ( |
| 286 | patch.object( |
| 287 | tools._file_helper, "substitute_file_uploads" |
| 288 | ) as mock_upload, |
| 289 | patch.object( |
| 290 | tools._file_helper, "substitute_file_downloads" |
| 291 | ) as mock_download, |
| 292 | ): |
| 293 | mock_upload.return_value = {} |
| 294 | mock_download.return_value = { |
| 295 | "data": {"file": "/downloaded/result.txt"}, |
| 296 | "error": None, |
| 297 | "successful": True, |
| 298 | } |
| 299 | |
| 300 | tools.execute( |
| 301 | slug="TEST_TOOL", |
| 302 | arguments={}, |
| 303 | dangerously_skip_version_check=True, |
| 304 | ) |
| 305 | |
| 306 | mock_download.assert_called_once() |
| 307 | |
| 308 | |
| 309 | class TestAutoUploadDownloadFilesDisabled: |
| 310 | """Test cases when auto_upload_download_files is disabled.""" |
| 311 | |
| 312 | def test_get_does_not_process_file_uploadable_when_disabled( |
| 313 | self, mock_client, mock_provider |
| 314 | ): |
| 315 | """Test that _get does not process file_uploadable fields when auto_upload_download_files is False.""" |
| 316 | tools = Tools( |
| 317 | client=mock_client, |
| 318 | provider=mock_provider, |
| 319 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 320 | ) |
| 321 | |
| 322 | # Create tool with file_uploadable field |
| 323 | mock_tool = create_mock_tool( |
| 324 | slug="TEST_TOOL", |
| 325 | toolkit_slug="test_toolkit", |
| 326 | input_parameters={ |
| 327 | "type": "object", |
| 328 | "properties": { |
| 329 | "file": { |
| 330 | "type": "string", |
| 331 | "file_uploadable": True, |
| 332 | "description": "Upload a file", |
| 333 | }, |
| 334 | }, |
| 335 | }, |
| 336 | ) |
| 337 | |
| 338 | # Mock client.tools.list |
| 339 | mock_client.tools.list.return_value = Mock(items=[mock_tool]) |
| 340 | |
| 341 | # Mock provider.wrap_tools |
| 342 | mock_provider.wrap_tools = Mock(return_value=[]) |
| 343 | |
| 344 | # Get tools |
| 345 | tools._get(user_id="test-user", tools=["TEST_TOOL"]) |
| 346 | |
| 347 | # Verify file_uploadable schema was NOT processed (not converted to path format) |
| 348 | wrap_tools_call = mock_provider.wrap_tools.call_args |
| 349 | processed_tools = wrap_tools_call[1]["tools"] |
| 350 | file_param = processed_tools[0].input_parameters["properties"]["file"] |
| 351 | |
| 352 | # Should NOT have format: "path" since auto_upload_download_files is False |
| 353 | assert file_param.get("format") is None |
| 354 | assert file_param.get("file_uploadable") is True |
| 355 | |
| 356 | def test_get_still_enhances_descriptions_when_disabled( |
| 357 | self, mock_client, mock_provider |
| 358 | ): |
| 359 | """Test that _get still adds type hints and required notes when auto_upload_download_files is False. |
| 360 | |
| 361 | The auto_upload_download_files flag should only control file upload/download behavior, |
| 362 | not the description enhancements (type hints and required notes). |
| 363 | """ |
| 364 | tools = Tools( |
| 365 | client=mock_client, |
| 366 | provider=mock_provider, |
| 367 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 368 | ) |
| 369 | |
| 370 | # Create tool with various parameter types |
| 371 | mock_tool = create_mock_tool( |
| 372 | slug="TEST_TOOL", |
| 373 | toolkit_slug="test_toolkit", |
| 374 | input_parameters={ |
| 375 | "type": "object", |
| 376 | "required": ["required_param"], |
| 377 | "properties": { |
| 378 | "text_param": { |
| 379 | "type": "string", |
| 380 | "description": "A text parameter", |
| 381 | }, |
| 382 | "required_param": { |
| 383 | "type": "integer", |
| 384 | "description": "A required parameter", |
| 385 | }, |
| 386 | }, |
| 387 | }, |
| 388 | ) |
| 389 | |
| 390 | # Mock client.tools.list |
| 391 | mock_client.tools.list.return_value = Mock(items=[mock_tool]) |
| 392 | |
| 393 | # Mock provider.wrap_tools |
| 394 | mock_provider.wrap_tools = Mock(return_value=[]) |
| 395 | |
| 396 | # Get tools |
| 397 | tools._get(user_id="test-user", tools=["TEST_TOOL"]) |
| 398 | |
| 399 | # Verify description enhancements were applied |
| 400 | wrap_tools_call = mock_provider.wrap_tools.call_args |
| 401 | processed_tools = wrap_tools_call[1]["tools"] |
| 402 | props = processed_tools[0].input_parameters["properties"] |
| 403 | |
| 404 | # Type hints should be added |
| 405 | assert ( |
| 406 | "Please provide a value of type string" |
| 407 | in props["text_param"]["description"] |
| 408 | ) |
| 409 | assert ( |
| 410 | "Please provide a value of type integer" |
| 411 | in props["required_param"]["description"] |
| 412 | ) |
| 413 | |
| 414 | # Required notes should be added |
| 415 | assert "This parameter is required" in props["required_param"]["description"] |
| 416 | |
| 417 | def test_execute_skips_file_uploads_when_disabled(self, mock_client, mock_provider): |
| 418 | """Test that execute does not call substitute_file_uploads when disabled.""" |
| 419 | tools = Tools( |
| 420 | client=mock_client, |
| 421 | provider=mock_provider, |
| 422 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 423 | ) |
| 424 | |
| 425 | mock_tool = create_mock_tool( |
| 426 | slug="TEST_TOOL", |
| 427 | toolkit_slug="test_toolkit", |
| 428 | input_parameters={ |
| 429 | "type": "object", |
| 430 | "properties": { |
| 431 | "file": {"type": "string", "file_uploadable": True}, |
| 432 | }, |
| 433 | }, |
| 434 | ) |
| 435 | |
| 436 | with patch.object( |
| 437 | tools, "get_raw_composio_tool_by_slug", return_value=mock_tool |
| 438 | ): |
| 439 | mock_execute_response = Mock() |
| 440 | mock_execute_response.model_dump.return_value = { |
| 441 | "data": {"result": "success"}, |
| 442 | "error": None, |
| 443 | "successful": True, |
| 444 | } |
| 445 | mock_client.tools.execute.return_value = mock_execute_response |
| 446 | |
| 447 | # Patch substitute_file_uploads to verify it's NOT called |
| 448 | with patch.object( |
| 449 | tools._file_helper, "substitute_file_uploads" |
| 450 | ) as mock_substitute: |
| 451 | tools.execute( |
| 452 | slug="TEST_TOOL", |
| 453 | arguments={"file": "/path/to/file.txt"}, |
| 454 | dangerously_skip_version_check=True, |
| 455 | ) |
| 456 | |
| 457 | mock_substitute.assert_not_called() |
| 458 | |
| 459 | def test_execute_drops_empty_file_values_when_disabled( |
| 460 | self, mock_client, mock_provider |
| 461 | ): |
| 462 | """Issue #4233: with auto-upload off, ``attachment: ""`` must be |
| 463 | omitted from the request instead of forwarded to the backend, while a |
| 464 | real value is forwarded as-is (not uploaded).""" |
| 465 | tools = Tools( |
| 466 | client=mock_client, |
| 467 | provider=mock_provider, |
| 468 | toolkit_versions={"gmail": "20251201_01"}, |
| 469 | ) |
| 470 | |
| 471 | file_uploadable = { |
| 472 | "type": "object", |
| 473 | "file_uploadable": True, |
| 474 | "properties": { |
| 475 | "name": {"type": "string"}, |
| 476 | "mimetype": {"type": "string"}, |
| 477 | "s3key": {"type": "string"}, |
| 478 | }, |
| 479 | } |
| 480 | mock_tool = create_mock_tool( |
| 481 | slug="GMAIL_CREATE_DRAFT", |
| 482 | toolkit_slug="gmail", |
| 483 | input_parameters={ |
| 484 | "type": "object", |
| 485 | "properties": { |
| 486 | "subject": {"type": "string"}, |
| 487 | "attachment": { |
| 488 | "anyOf": [ |
| 489 | file_uploadable, |
| 490 | {"type": "array", "items": file_uploadable}, |
| 491 | {"type": "null"}, |
| 492 | ] |
| 493 | }, |
| 494 | }, |
| 495 | "required": ["attachment"], |
| 496 | }, |
| 497 | ) |
| 498 | mock_execute_response = Mock() |
| 499 | mock_execute_response.model_dump.return_value = { |
| 500 | "data": {}, |
| 501 | "error": None, |
| 502 | "successful": True, |
| 503 | } |
| 504 | mock_client.tools.execute.return_value = mock_execute_response |
| 505 | |
| 506 | with patch.object( |
| 507 | tools, "get_raw_composio_tool_by_slug", return_value=mock_tool |
| 508 | ): |
| 509 | for value, expected in ( |
| 510 | ("", {"subject": "Test"}), |
| 511 | (None, {"subject": "Test", "attachment": None}), |
| 512 | ( |
| 513 | "/path/to/file.txt", |
| 514 | {"subject": "Test", "attachment": "/path/to/file.txt"}, |
| 515 | ), |
| 516 | ): |
| 517 | mock_client.tools.execute.reset_mock() |
| 518 | arguments = {"subject": "Test", "attachment": value} |
| 519 | tools.execute( |
| 520 | slug="GMAIL_CREATE_DRAFT", |
| 521 | arguments=arguments, |
| 522 | dangerously_skip_version_check=True, |
| 523 | ) |
| 524 | sent = mock_client.tools.execute.call_args.kwargs["arguments"] |
| 525 | assert sent == expected, value |
| 526 | assert arguments == {"subject": "Test", "attachment": value} |
| 527 | |
| 528 | def test_execute_skips_file_downloads_when_disabled( |
| 529 | self, mock_client, mock_provider |
| 530 | ): |
| 531 | """Test that execute does not call substitute_file_downloads when disabled.""" |
| 532 | tools = Tools( |
| 533 | client=mock_client, |
| 534 | provider=mock_provider, |
| 535 | toolkit_versions={"test_toolkit": "20251201_01"}, |
| 536 | ) |
| 537 | |
| 538 | mock_tool = create_mock_tool( |
| 539 | slug="TEST_TOOL", |
| 540 | toolkit_slug="test_toolkit", |
| 541 | output_parameters={ |
| 542 | "type": "object", |
| 543 | "properties": { |
| 544 | "file": {"type": "object", "file_downloadable": True}, |
| 545 | }, |
| 546 | }, |
| 547 | ) |
| 548 | |
| 549 | with patch.object( |
| 550 | tools, "get_raw_composio_tool_by_slug", return_value=mock_tool |
| 551 | ): |
| 552 | mock_execute_response = Mock() |
| 553 | mock_execute_response.model_dump.return_value = { |
| 554 | "data": { |
| 555 | "file": { |
| 556 | "name": "result.txt", |
| 557 | "mimetype": "text/plain", |
| 558 | "s3url": "https://s3.example.com/result.txt", |
| 559 | } |
| 560 | }, |
| 561 | "error": None, |
| 562 | "successful": True, |
| 563 | } |
| 564 | mock_client.tools.execute.return_value = mock_execute_response |
| 565 | |
| 566 | # Patch substitute_file_downloads to verify it's NOT called |
| 567 | with patch.object( |
| 568 | tools._file_helper, "substitute_file_downloads" |
| 569 | ) as mock_substitute: |
| 570 | result = tools.execute( |
| 571 | slug="TEST_TOOL", |
| 572 | arguments={}, |
| 573 | dangerously_skip_version_check=True, |
| 574 | ) |
| 575 | |
| 576 | mock_substitute.assert_not_called() |
| 577 | |
| 578 | # Verify raw S3 URL is preserved in response |
| 579 | assert ( |
| 580 | result["data"]["file"]["s3url"] |
| 581 | == "https://s3.example.com/result.txt" |
| 582 | ) |
| 583 | |
| 584 | |
| 585 | class TestAutoUploadDownloadFilesWithSDK: |
| 586 | """Test cases for auto_upload_download_files with SDK initialization.""" |
| 587 | |
| 588 | def test_sdk_passes_auto_upload_download_off_to_tools_by_default(self): |
| 589 | """Test that Composio SDK disables automatic file upload/download by default.""" |
| 590 | from composio.sdk import Composio |
| 591 | |
| 592 | with patch("composio.sdk.HttpClient"): |
| 593 | with patch.object(Tools, "__init__", return_value=None) as mock_init: |
| 594 | mock_provider = Mock() |
| 595 | mock_provider.name = "test" |
| 596 | |
| 597 | Composio( |
| 598 | provider=mock_provider, |
| 599 | api_key="test-key", |
| 600 | ) |
| 601 | |
| 602 | mock_init.assert_called() |
| 603 | call_kwargs = mock_init.call_args[1] |
| 604 | assert ( |
| 605 | call_kwargs.get("dangerously_allow_auto_upload_download_files") |
| 606 | is False |
| 607 | ) |
| 608 | |
| 609 | def test_sdk_passes_true_when_dangerously_enabled(self): |
| 610 | """Test that Composio SDK passes through dangerously_allow_auto_upload_download_files.""" |
| 611 | from composio.sdk import Composio |
| 612 | |
| 613 | with patch("composio.sdk.HttpClient"): |
| 614 | with patch.object(Tools, "__init__", return_value=None) as mock_init: |
| 615 | mock_provider = Mock() |
| 616 | mock_provider.name = "test" |
| 617 | |
| 618 | Composio( |
| 619 | provider=mock_provider, |
| 620 | api_key="test-key", |
| 621 | dangerously_allow_auto_upload_download_files=True, |
| 622 | ) |
| 623 | |
| 624 | mock_init.assert_called() |
| 625 | call_kwargs = mock_init.call_args[1] |
| 626 | assert ( |
| 627 | call_kwargs.get("dangerously_allow_auto_upload_download_files") |
| 628 | is True |
| 629 | ) |