fix: replace wallet API heredoc with echo commands in api-endpoint-tests.yml
API ENDPOINT TESTS YAML FIX: Continue fixing YAML syntax errors Issues Fixed: ❌ Additional heredoc causing YAML parsing issues ❌ Wallet API test script creation failing ❌ Multi-line Python content being parsed as YAML Root Cause: - Remaining heredoc syntax in wallet API section - YAML parser still failing on multi-line content - Need to convert all heredocs to echo commands Solution Applied: ✅ Replaced wallet API heredoc with echo commands ✅ Line-by-line Python script creation for wallet tests ✅ Proper YAML syntax for wallet API section ✅ Maintained complete wallet API functionality Implementation Changes: - Removed wallet API heredoc syntax completely - Used echo commands for each Python line - Proper shell escaping for quotes and strings - Line-by-line file construction Generated Content: - Complete wallet API test script - Wallet health check functions - Wallet endpoint testing logic - Error handling and validation Impact: - YAML file now validates for wallet section - Wallet API test creation works properly - Progress toward complete YAML syntax validation - Need to fix remaining 2 heredocs for complete solution This continues the fix - 2 more heredocs (blockchain RPC and performance) need to be addressed for complete YAML syntax validation.
This commit is contained in:
@@ -282,49 +282,47 @@ jobs:
|
||||
echo "🧪 Testing Wallet API endpoints..."
|
||||
|
||||
# Create wallet API test
|
||||
cat > test_wallet_api.py << 'EOF'
|
||||
import requests
|
||||
import json
|
||||
|
||||
def test_wallet_health():
|
||||
try:
|
||||
response = requests.get('http://localhost:8002/', timeout=5)
|
||||
print(f"✅ Wallet health check: {response.status_code}")
|
||||
return response.status_code == 200
|
||||
except Exception as e:
|
||||
print(f"❌ Wallet health error: {e}")
|
||||
return False
|
||||
|
||||
def test_wallet_endpoints():
|
||||
endpoints = [
|
||||
'http://localhost:8002/',
|
||||
'http://localhost:8002/health',
|
||||
'http://localhost:8002/wallets'
|
||||
]
|
||||
|
||||
results = []
|
||||
for endpoint in endpoints:
|
||||
try:
|
||||
response = requests.get(endpoint, timeout=5)
|
||||
print(f"✅ {endpoint}: {response.status_code}")
|
||||
results.append(response.status_code == 200)
|
||||
except Exception as e:
|
||||
print(f"❌ {endpoint}: {e}")
|
||||
results.append(False)
|
||||
|
||||
return all(results)
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🧪 Testing Wallet API...")
|
||||
|
||||
health_ok = test_wallet_health()
|
||||
endpoints_ok = test_wallet_endpoints()
|
||||
|
||||
if health_ok and endpoints_ok:
|
||||
print("✅ Wallet API tests passed")
|
||||
else:
|
||||
print("❌ Wallet API tests failed")
|
||||
EOF
|
||||
echo 'import requests' > test_wallet_api.py
|
||||
echo 'import json' >> test_wallet_api.py
|
||||
echo '' >> test_wallet_api.py
|
||||
echo 'def test_wallet_health():' >> test_wallet_api.py
|
||||
echo ' try:' >> test_wallet_api.py
|
||||
echo ' response = requests.get('"'"'http://localhost:8002/'"'"', timeout=5)' >> test_wallet_api.py
|
||||
echo ' print(f"✅ Wallet health check: {response.status_code}")' >> test_wallet_api.py
|
||||
echo ' return response.status_code == 200' >> test_wallet_api.py
|
||||
echo ' except Exception as e:' >> test_wallet_api.py
|
||||
echo ' print(f"❌ Wallet health error: {e}")' >> test_wallet_api.py
|
||||
echo ' return False' >> test_wallet_api.py
|
||||
echo '' >> test_wallet_api.py
|
||||
echo 'def test_wallet_endpoints():' >> test_wallet_api.py
|
||||
echo ' endpoints = [' >> test_wallet_api.py
|
||||
echo ' '"'"'http://localhost:8002/'"'"',' >> test_wallet_api.py
|
||||
echo ' '"'"'http://localhost:8002/health'"'"',' >> test_wallet_api.py
|
||||
echo ' '"'"'http://localhost:8002/wallets'"'"'' >> test_wallet_api.py
|
||||
echo ' ]' >> test_wallet_api.py
|
||||
echo ' ' >> test_wallet_api.py
|
||||
echo ' results = []' >> test_wallet_api.py
|
||||
echo ' for endpoint in endpoints:' >> test_wallet_api.py
|
||||
echo ' try:' >> test_wallet_api.py
|
||||
echo ' response = requests.get(endpoint, timeout=5)' >> test_wallet_api.py
|
||||
echo ' print(f"✅ {endpoint}: {response.status_code}")' >> test_wallet_api.py
|
||||
echo ' results.append(response.status_code == 200)' >> test_wallet_api.py
|
||||
echo ' except Exception as e:' >> test_wallet_api.py
|
||||
echo ' print(f"❌ {endpoint}: {e}")' >> test_wallet_api.py
|
||||
echo ' results.append(False)' >> test_wallet_api.py
|
||||
echo ' ' >> test_wallet_api.py
|
||||
echo ' return all(results)' >> test_wallet_api.py
|
||||
echo '' >> test_wallet_api.py
|
||||
echo 'if __name__ == "__main__":' >> test_wallet_api.py
|
||||
echo ' print("🧪 Testing Wallet API...")' >> test_wallet_api.py
|
||||
echo ' ' >> test_wallet_api.py
|
||||
echo ' health_ok = test_wallet_health()' >> test_wallet_api.py
|
||||
echo ' endpoints_ok = test_wallet_endpoints()' >> test_wallet_api.py
|
||||
echo ' ' >> test_wallet_api.py
|
||||
echo ' if health_ok and endpoints_ok:' >> test_wallet_api.py
|
||||
echo ' print("✅ Wallet API tests passed")' >> test_wallet_api.py
|
||||
echo ' else:' >> test_wallet_api.py
|
||||
echo ' print("❌ Wallet API tests failed")' >> test_wallet_api.py
|
||||
|
||||
python test_wallet_api.py
|
||||
|
||||
|
||||
Reference in New Issue
Block a user