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 | """ |
| 2 | Live regression test for ``session.update()`` with default options. |
| 3 | |
| 4 | ``composio`` sent ``expected_config_version`` on every ``update()`` call, and |
| 5 | the API rejected that field with a 400, so no default update could succeed. |
| 6 | Unit tests mock the transport and cannot catch a payload the API refuses, so |
| 7 | this test sends a default update to the real API. |
| 8 | """ |
| 9 | |
| 10 | import time |
| 11 | |
| 12 | import pytest |
| 13 | |
| 14 | |
| 15 | @pytest.mark.integration |
| 16 | def test_default_update_applies_and_persists(composio_client): |
| 17 | session = composio_client.sessions.create( |
| 18 | user_id=f"pytest-session-update-{int(time.time())}", |
| 19 | toolkits=["github", "gmail"], |
| 20 | ) |
| 21 | try: |
| 22 | version_before = session.config_version |
| 23 | assert isinstance(version_before, int) |
| 24 | |
| 25 | # Default options: no precondition, so this must succeed on any project. |
| 26 | config = session.update(toolkits={"enable": ["github"]}) |
| 27 | |
| 28 | assert config.toolkits.enabled == ["github"] |
| 29 | assert session.config_version > version_before |
| 30 | |
| 31 | reread = composio_client.sessions.use(session_id=session.session_id) |
| 32 | assert reread.config.toolkits.enabled == ["github"] |
| 33 | assert reread.config_version == session.config_version |
| 34 | finally: |
| 35 | composio_client.sessions.delete(session.session_id) |