JK
JustKalm
Quality Assurance

Testing Guide

Best practices for testing your JustKalm integration. From unit tests to CI/CD pipelines, we've got you covered.

Testing Strategy

Unit Tests

Mock the JustKalm client to test your business logic in isolation. Fast, reliable, no API calls.

~5ms per test

Integration Tests

Use test mode API keys to verify your integration works end-to-end with real API calls.

~200ms per test

E2E Tests

Full end-to-end tests with your UI. Use test mode for predictable results.

~2s per test

Code Examples

Python Unit Test
import pytest
from unittest.mock import patch, MagicMock
from justkalm import JustKalm

class TestValuation:
    @patch('justkalm.client.requests.post')
    def test_valuate_returns_price_range(self, mock_post):
        # Arrange
        mock_response = MagicMock()
        mock_response.json.return_value = {
            "price_min": 150,
            "price_max": 250,
            "confidence": 0.92,
            "currency": "USD"
        }
        mock_response.status_code = 200
        mock_post.return_value = mock_response
        
        client = JustKalm(api_key="jk_test_xxx")
        
        # Act
        result = client.valuate(url="https://example.com/item")
        
        # Assert
        assert result.price_min == 150
        assert result.price_max == 250
        assert result.confidence > 0.9

Test Fixtures

JustKalm provides special test URLs that return predictable responses for testing:

Test URLResponseUse Case
test://success200 OK with valuationHappy path testing
test://not-found404 Not FoundError handling
test://rate-limit429 Too Many RequestsRate limit handling
test://timeoutConnection timeout (30s)Timeout handling
test://invalid-response500 Server ErrorServer error handling
test://slow200 OK after 5s delaySlow response handling
test://partial200 with partial dataMissing fields

Best Practices

Follow these steps to set up testing:

  1. 1Get a test API key from the dashboard
  2. 2Set JUSTKALM_API_KEY environment variable
  3. 3Install testing framework (pytest, vitest, jest)
  4. 4Create test fixtures for common responses
  5. 5Run unit tests first, then integration

What to Test

Should Test

  • API response parsing and mapping
  • Error handling for all error codes
  • Retry logic and backoff behavior
  • Webhook signature verification
  • Rate limit handling
  • Timeout behavior
  • Cache invalidation
  • Business logic using valuations

Can Skip (SDK Handles)

  • HTTP connection handling
  • Request serialization
  • Response deserialization
  • Authentication header injection
  • Automatic retries (already tested)
  • Keep-alive connection pooling
  • Request/response logging

Need Help With Testing?

Our team is here to help you set up a robust testing strategy.

© 2025 JustKalm. Ship with confidence.