File size: 3,048 Bytes
eebf5c4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# Quick Test Guide - Real Data Implementation
## π Quick Start (30 seconds)
```bash
# 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)
```json
{
"mode": "real",
"cryptocurrencies": [...],
"source": "CoinGecko",
"timestamp": "2025-01-15T10:30:00Z"
}
```
### Mock Data (if USE_MOCK_DATA=true)
```json
{
"mode": "mock",
"cryptocurrencies": [...]
}
```
## π§ͺ Full Test Suite
```bash
python test_real_data.py
```
Expected: 4/5 tests pass (DeFi returns 503 as expected)
## π Test Each Endpoint
```bash
# 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
```bash
curl http://localhost:8000/api/market | grep '"mode"'
```
Should show: `"mode": "real"`
### Check 2: Source Field
```bash
curl http://localhost:8000/api/market | grep '"source"'
```
Should show: `"source": "CoinGecko"`
### Check 3: Timestamp
```bash
curl http://localhost:8000/api/market | grep '"timestamp"'
```
Should show current time (not static)
### Check 4: Database Storage
```bash
# 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
```bash
# 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**:
```bash
# 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!** π
|