测试缓存刷新功能
()
| 210 | print(f" {source}: {count} 次失败") |
| 211 | |
| 212 | def test_cache_refresh(): |
| 213 | """测试缓存刷新功能""" |
| 214 | print("\n🔄 测试缓存刷新功能") |
| 215 | try: |
| 216 | start_time = time.time() |
| 217 | response = requests.post(f"{API_KEY_MANAGER_URL}/refresh_cache", timeout=30) |
| 218 | end_time = time.time() |
| 219 | |
| 220 | if response.status_code == 200: |
| 221 | print(f"✅ 缓存刷新成功,耗时: {end_time - start_time:.2f}s") |
| 222 | result = response.json() |
| 223 | print(f"📝 响应: {result.get('message', 'N/A')}") |
| 224 | print(f"📅 时间戳: {result.get('timestamp', 'N/A')}") |
| 225 | else: |
| 226 | print(f"❌ 缓存刷新失败: HTTP {response.status_code}") |
| 227 | print(f"响应内容: {response.text[:200]}") |
| 228 | except Exception as e: |
| 229 | print(f"❌ 缓存刷新异常: {str(e)}") |
| 230 | |
| 231 | def test_stats_endpoint(): |
| 232 | """测试统计信息端点""" |