
from app import create_app

app = create_app()
client = app.test_client()

endpoints = [
    ('GET', '/api/health', 'Health check'),
    ('GET', '/api/marketplace/categories', 'Categories'),
    ('GET', '/api/marketplace/jobs', 'Jobs'),  
    ('GET', '/api/gamification/leaderboards/weekly', 'Leaderboards'),
    ('POST', '/api/legal/validate-abn', 'ABN validation', {'abn': '12345678901'}),
    ('GET', '/api/gamification/users/1/achievements', 'Achievements')
]

print("🔍 Testing RateRight API Endpoints...")
print("=" * 50)

for method, url, name, *data in endpoints:
    try:
        if method == 'POST':
            response = client.post(url, json=data[0])
        else:
            response = client.get(url)
        
        # Consider 200, 400, and 404 as "working" (proper responses)
        status = '✅' if response.status_code in [200, 400, 404] else '❌'
        print(f'{status} {name}: {response.status_code}')
        
        # Show response content for debugging
        if response.status_code >= 500:
            try:
                error_data = response.get_json()
                print(f"   Error: {error_data.get('error', 'Unknown error')}")
            except:
                print(f"   Error: {response.data.decode()[:100]}...")
                
    except Exception as e:
        print(f'❌ {name}: Exception - {str(e)}')

print("=" * 50)
print("✅ = Working endpoint (200, 400, or 404 response)")
print("❌ = Failing endpoint (500+ or exception)")
