ArmorIQ SDK

Testing

Use mocks to validate invocation behavior.

Testing

import unittest
from unittest.mock import patch

class TestAgent(unittest.TestCase):
    def setUp(self):
        self.client = ArmorIQClient(
            api_key="ak_live_" + "a" * 64,
            user_id="test_user",
            agent_id="test_agent"
        )

    @patch('armoriq_sdk.client.ArmorIQClient.invoke')
    def test_successful_invocation(self, mock_invoke):
        # Mock successful response
        mock_invoke.return_value = {
            "success": True,
            "data": {"result": 42},
            "execution_time_ms": 100
        }

        result = self.client.invoke("math-mcp", "calculate", "token", {})

        self.assertTrue(result["success"])
        self.assertEqual(result["data"]["result"], 42)

    @patch('armoriq_sdk.client.ArmorIQClient.get_intent_token')
    def test_token_expiration_handling(self, mock_get_token):
        # First call returns expired token
        # Second call returns fresh token
        mock_get_token.side_effect = [
            {"token": "expired_token", "expires_at": 0},
            {"token": "fresh_token", "expires_at": 9999999999}
        ]

        # Test auto-refresh logic
        ...

On this page