Quick Test Guide - Real Data Implementation
π Quick Start (30 seconds)
# 1. Start the server
python main.py
# 2. In another terminal, test real data
curl http://localhost:8000/api/market
# 3. Check it's real (not mock)
# Look for: "mode": "real" and "source": "CoinGecko"
β What to Expect
Real Data (Default)
{
"mode": "real",
"cryptocurrencies": [...],
"source": "CoinGecko",
"timestamp": "2025-01-15T10:30:00Z"
}
Mock Data (if USE_MOCK_DATA=true)
{
"mode": "mock",
"cryptocurrencies": [...]
}
π§ͺ Full Test Suite
python test_real_data.py
Expected: 4/5 tests pass (DeFi returns 503 as expected)
π Test Each Endpoint
# Market data
curl http://localhost:8000/api/market
# Historical data (after calling /api/market once)
curl "http://localhost:8000/api/market/history?symbol=BTC&limit=5"
# Sentiment
curl http://localhost:8000/api/sentiment
# Trending
curl http://localhost:8000/api/trending
# DeFi (returns 503 - not configured)
curl http://localhost:8000/api/defi
# Sentiment ML (returns 501 - not implemented)
curl -X POST http://localhost:8000/api/hf/run-sentiment \
-H "Content-Type: application/json" \
-d '{"texts": ["test"]}'
π Verify Real Data
Check 1: Mode Field
curl http://localhost:8000/api/market | grep '"mode"'
Should show: "mode": "real"
Check 2: Source Field
curl http://localhost:8000/api/market | grep '"source"'
Should show: "source": "CoinGecko"
Check 3: Timestamp
curl http://localhost:8000/api/market | grep '"timestamp"'
Should show current time (not static)
Check 4: Database Storage
# Call market endpoint
curl http://localhost:8000/api/market
# Check history (should have records)
curl "http://localhost:8000/api/market/history?symbol=BTC&limit=1"
Should return at least 1 record
π Test Mock Mode
# Start in mock mode
USE_MOCK_DATA=true python main.py
# Test
curl http://localhost:8000/api/market | grep '"mode"'
Should show: "mode": "mock"
β Common Issues
"Provider not configured"
Fix: Check providers_config_extended.json exists and has coingecko provider
"Connection refused"
Fix: Ensure server is running on port 8000
Still showing mock data
Fix:
# Check environment
env | grep USE_MOCK_DATA
# Should be empty or "false"
# If "true", restart without it
python main.py
π Full Documentation
- Complete Guide:
REAL_DATA_IMPLEMENTATION.md - Changes Summary:
CHANGES_SUMMARY.md - API Docs: http://localhost:8000/docs
β¨ Success Indicators
β
"mode": "real" in responses
β
"source": "CoinGecko" or "alternative.me"
β
Current timestamps (not static)
β
Database history accumulates
β
503/501 errors for unimplemented (not mock data)
You're all set! π