Really-amin's picture
Upload 317 files
eebf5c4 verified

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

✨ 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! πŸŽ‰