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:
2026-03-27 23:55:17 +01:00
parent a8b631edc0
commit 27510ebf2c

View File

@@ -282,49 +282,47 @@ jobs:
echo "🧪 Testing Wallet API endpoints..." echo "🧪 Testing Wallet API endpoints..."
# Create wallet API test # Create wallet API test
cat > test_wallet_api.py << 'EOF' echo 'import requests' > test_wallet_api.py
import requests echo 'import json' >> test_wallet_api.py
import json echo '' >> test_wallet_api.py
echo 'def test_wallet_health():' >> test_wallet_api.py
def test_wallet_health(): echo ' try:' >> test_wallet_api.py
try: echo ' response = requests.get('"'"'http://localhost:8002/'"'"', timeout=5)' >> test_wallet_api.py
response = requests.get('http://localhost:8002/', timeout=5) echo ' print(f"✅ Wallet health check: {response.status_code}")' >> test_wallet_api.py
print(f"✅ Wallet health check: {response.status_code}") echo ' return response.status_code == 200' >> test_wallet_api.py
return response.status_code == 200 echo ' except Exception as e:' >> test_wallet_api.py
except Exception as e: echo ' print(f"❌ Wallet health error: {e}")' >> test_wallet_api.py
print(f"❌ Wallet health error: {e}") echo ' return False' >> test_wallet_api.py
return False echo '' >> test_wallet_api.py
echo 'def test_wallet_endpoints():' >> test_wallet_api.py
def test_wallet_endpoints(): echo ' endpoints = [' >> test_wallet_api.py
endpoints = [ echo ' '"'"'http://localhost:8002/'"'"',' >> test_wallet_api.py
'http://localhost:8002/', echo ' '"'"'http://localhost:8002/health'"'"',' >> test_wallet_api.py
'http://localhost:8002/health', echo ' '"'"'http://localhost:8002/wallets'"'"'' >> test_wallet_api.py
'http://localhost:8002/wallets' echo ' ]' >> test_wallet_api.py
] echo ' ' >> test_wallet_api.py
echo ' results = []' >> test_wallet_api.py
results = [] echo ' for endpoint in endpoints:' >> test_wallet_api.py
for endpoint in endpoints: echo ' try:' >> test_wallet_api.py
try: echo ' response = requests.get(endpoint, timeout=5)' >> test_wallet_api.py
response = requests.get(endpoint, timeout=5) echo ' print(f"✅ {endpoint}: {response.status_code}")' >> test_wallet_api.py
print(f"✅ {endpoint}: {response.status_code}") echo ' results.append(response.status_code == 200)' >> test_wallet_api.py
results.append(response.status_code == 200) echo ' except Exception as e:' >> test_wallet_api.py
except Exception as e: echo ' print(f"❌ {endpoint}: {e}")' >> test_wallet_api.py
print(f"❌ {endpoint}: {e}") echo ' results.append(False)' >> test_wallet_api.py
results.append(False) echo ' ' >> test_wallet_api.py
echo ' return all(results)' >> test_wallet_api.py
return all(results) echo '' >> test_wallet_api.py
echo 'if __name__ == "__main__":' >> test_wallet_api.py
if __name__ == "__main__": echo ' print("🧪 Testing Wallet API...")' >> test_wallet_api.py
print("🧪 Testing Wallet API...") echo ' ' >> test_wallet_api.py
echo ' health_ok = test_wallet_health()' >> test_wallet_api.py
health_ok = test_wallet_health() echo ' endpoints_ok = test_wallet_endpoints()' >> test_wallet_api.py
endpoints_ok = test_wallet_endpoints() echo ' ' >> test_wallet_api.py
echo ' if health_ok and endpoints_ok:' >> test_wallet_api.py
if health_ok and endpoints_ok: echo ' print("✅ Wallet API tests passed")' >> test_wallet_api.py
print("✅ Wallet API tests passed") echo ' else:' >> test_wallet_api.py
else: echo ' print("❌ Wallet API tests failed")' >> test_wallet_api.py
print("❌ Wallet API tests failed")
EOF
python test_wallet_api.py python test_wallet_api.py