Documentation Index
Fetch the complete documentation index at: https://docs.julep.ai/llms.txt
Use this file to discover all available pages before exploring further.
Testing
Learn how to effectively test your Julep SDK implementations.
Unit Testing
Mocking API Responses
from unittest.mock import patch
def test_agent_creation():
with patch('julep.Client') as MockClient:
mock_client = MockClient()
mock_client.agents.create.return_value = {
"id": "test_id",
"name": "Test Agent"
}
agent = mock_client.agents.create(name="Test Agent")
assert agent["name"] == "Test Agent"
Testing Error Handling
def test_api_error_handling():
with patch('julep.Client') as MockClient:
mock_client = MockClient()
mock_client.agents.get.side_effect = julep.APIError(
message="Not found",
status_code=404
)
with pytest.raises(julep.APIError):
mock_client.agents.get("nonexistent_id")
Integration Testing
Test Client Setup
import pytest
@pytest.fixture
def test_client():
return Client(
api_key="test_key",
base_url="https://test-api.julep.ai"
)
def test_end_to_end(test_client):
agent = test_client.agents.create(name="Test Agent")
assert agent.id is not None
Best Practices
- Use test fixtures for common setup
- Mock external API calls in unit tests
- Use integration tests for end-to-end validation
- Test error cases and edge conditions
- Maintain a comprehensive test suite