Testing Guide
Testing Guide
Comprehensive guide for testing your Sports Stack integration and data syncs.
Overview
This guide covers testing strategies for:
- Data provider syncs
- API endpoints
- Webhook integrations
- Data validation
Testing Data Syncs
Browser-Based Testing
Recommended: Use the CMS UI for testing syncs
Step 1: Navigate to Provider
http://localhost:4001/integrations/data_providers/{provider}?tab=Sync+Data&league={league}
Examples:
- NFL:
http://localhost:4001/integrations/data_providers/sportradar?tab=Sync+Data&league=nfl - NBA:
http://localhost:4001/integrations/data_providers/sportradar?tab=Sync+Data&league=nba
Step 2: Trigger Sync
- Find the route you want to test (e.g., "Teams", "League Hierarchy")
- Click "Sync now" button
- Wait 3-10 seconds for processing
- Check Recent API Calls for status
Step 3: Validate Results
# Validate league sync
mix run validate_league_sync.exs {league}
# Example
mix run validate_league_sync.exs nflSystematic League Testing
Test multiple leagues at once:
# Test all leagues
mix run test_all_leagues.exs
# Test specific league
mix run validate_league_sync.exs nflExpected Results by League
NFL:
- Seasons: ~10-15 (PRE, REG, POST)
- Active Teams: 32
- All teams have colors and metadata
NBA:
- Seasons: ~5-10
- Active Teams: 30
- All teams have colors and metadata
NHL:
- Seasons: ~5-10
- Active Teams: 32
- All teams have colors and metadata
Testing API Endpoints
Using cURL
# Get teams
curl -X GET "https://api.sportsstack.io/api/v1/teams?league_id=nfl" \
-H "Authorization: Bearer YOUR_API_KEY"
# Get events
curl -X GET "https://api.sportsstack.io/api/v1/events?league_id=nfl&season_year=2024" \
-H "Authorization: Bearer YOUR_API_KEY"Using Postman
- Import OpenAPI spec:
openapi.json - Set up environment variables:
base_url:https://api.sportsstack.ioapi_key: Your API key
- Test endpoints from collection
Using Browser Developer Tools
- Open Developer Tools (F12)
- Navigate to Network tab
- Use CMS UI (makes API calls automatically)
- Inspect API requests/responses
Testing Webhooks
Using Webhook Tester
- Navigate to Admin → Webhook Tester
- Select your tenant
- Copy the generated test URL
- Configure destination with test URL
- Trigger a data change
- Inspect payload in tester interface
Using ngrok (Local Testing)
- Install ngrok:
brew install ngrok - Start your local server
- Expose with ngrok:
ngrok http 8000 - Copy HTTPS URL
- Configure webhook with ngrok URL
- Test webhook delivery
Signature Verification Testing
import hmac
import hashlib
def test_signature_verification():
payload = '{"test": "data"}'
secret = "test-secret"
# Generate expected signature
expected = hmac.new(
secret.encode('utf-8'),
payload.encode('utf-8'),
hashlib.sha256
).hexdigest()
# Verify signature matches
assert verify_webhook_signature(payload, expected, secret)Testing Filters
Season Type Filtering
- Navigate to Explore → Seasons
- Test filters:
- Regular: Shows only REG seasons
- Preseason: Shows only PRE seasons
- Postseason: Shows only PST seasons
- All: Shows all seasons
Team Status Filtering
- Navigate to Explore → Teams
- Test filters:
- ACTIVE: Shows active teams (default)
- INACTIVE: Shows inactive teams
- Verify counts match expectations
Event Status Filtering
- Navigate to Explore → Events
- Test filters:
- scheduled: Upcoming events
- in_progress: Live events
- completed: Finished events
- cancelled: Cancelled events
Integration Testing
Using Integration Test Framework
# Show available tests
elixir integration_tests/integration_test_runner.exs
# Test SportRadar NBA teams
elixir integration_tests/integration_test_runner.exs sportradar_nba_teams
# Test SportRadar NFL events
elixir integration_tests/integration_test_runner.exs sportradar_nfl_eventsManual Integration Testing
# In IEx
iex> Code.eval_file("integration_tests/integration_test.exs")
# Run specific test
iex> IntegrationTest.run("SportRadar", "nba", "teams", %{})
# Use helper functions
iex> IntegrationTest.Helpers.test_sportradar_nba_teams()Validation Scripts
League Sync Validation
# Validate specific league
mix run validate_league_sync.exs nfl
# Checks:
# - Season counts
# - Team counts (active/inactive)
# - Team colors
# - Team metadata (division/conference)Browser Sync Validation
# Validate browser-triggered sync
mix run browser_sync_validation.exs {provider} {league} {model}
# Example
mix run browser_sync_validation.exs sportradar nfl teamsTest Checklist
Before Testing
- Services running:
docker compose up -d - Database migrated:
mix ecto.migrate - Server running:
mix phx.server - Provider configured with valid API key
Data Sync Testing
- League Hierarchy sync completes
- Teams created with correct counts
- Teams have colors and metadata
- Seasons created correctly
- Events sync successfully
- Statistics sync correctly
API Testing
- Authentication works
- Rate limits respected
- Filters work correctly
- Pagination works
- Error handling works
Webhook Testing
- Webhook configuration works
- Payloads received correctly
- Signature verification works
- Idempotency implemented
- Error handling works
Common Test Scenarios
Scenario 1: Initial League Setup
- Sync League Hierarchy
- Sync Seasons
- Sync Teams
- Sync Events
- Validate all entities created
Scenario 2: Daily Updates
- Sync Events (scheduled)
- Sync Statistics (after games)
- Validate updates applied
Scenario 3: Webhook Integration
- Configure webhook destination
- Trigger data change
- Verify webhook received
- Verify signature
- Process webhook
Troubleshooting Tests
Sync Tests Failing
-
Check Provider Configuration:
- Verify API key is valid
- Check provider is active
- Verify league is selected
-
Check Trace Logs:
- Review API call logs
- Check conversion errors
- Verify processor matching
API Tests Failing
-
Check Authentication:
- Verify API key is correct
- Check Authorization header
- Verify key hasn't expired
-
Check Rate Limits:
- Verify not exceeding limits
- Check rate limit headers
- Wait for reset if needed
Webhook Tests Failing
-
Check Configuration:
- Verify webhook URL is correct
- Check shared secret matches
- Verify entity filters
-
Check Delivery:
- Review Recent API Calls
- Check webhook tester
- Verify endpoint is accessible
Related Documentation
- Data Sync Guide - How to sync data
- Webhooks Guide - Webhook testing
- API Reference - API endpoint testing
Support
For testing issues:
- Check Recent API Calls for errors
- Review Trace Logs for details
- Run Validation Scripts to verify data
- Contact support with test results
Updated 29 days ago
