47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
||
"""测试呼叫任务API功能"""
|
||
|
||
import sys
|
||
import os
|
||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||
|
||
from generic_api_task import generic_api_call
|
||
from datetime import datetime
|
||
|
||
def test_call_api_task():
|
||
"""测试呼叫任务API功能"""
|
||
print("=" * 60)
|
||
print(f"测试呼叫任务API功能 - {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||
print("=" * 60)
|
||
|
||
try:
|
||
# 测试默认呼叫任务API
|
||
print("🔧 测试默认呼叫任务API (main_api):")
|
||
result1 = generic_api_call()
|
||
print(f"✅ 默认呼叫结果: {result1['status']} - {result1['message']}")
|
||
|
||
print("\n🔧 测试备用呼叫任务API (backup_api):")
|
||
result2 = generic_api_call(api_key='backup_api')
|
||
print(f"✅ 备用呼叫结果: {result2['status']} - {result2['message']}")
|
||
|
||
print("\n🔧 测试自定义呼叫参数:")
|
||
custom_payload = {
|
||
'title': '呼叫任务测试',
|
||
'body': '这是自定义的呼叫任务参数',
|
||
'userId': 888
|
||
}
|
||
result3 = generic_api_call(api_key='main_api', custom_payload=custom_payload)
|
||
print(f"✅ 自定义呼叫结果: {result3['status']} - {result3['message']}")
|
||
|
||
print("\n" + "=" * 60)
|
||
print("📊 呼叫任务API测试完成!")
|
||
print("=" * 60)
|
||
|
||
return [result1, result2, result3]
|
||
|
||
except Exception as e:
|
||
print(f"❌ 测试失败: {str(e)}")
|
||
return None
|
||
|
||
if __name__ == "__main__":
|
||
test_call_api_task() |