import requests import json def test_projects_list_endpoint(): """Test the projects list endpoint""" base_url = "http://localhost:8001" try: # Test basic endpoint response = requests.get(f"{base_url}/api/v1/projects/") print(f"Status Code: {response.status_code}") print(f"Response Headers: {dict(response.headers)}") if response.status_code == 200: data = response.json() print(f"Response structure: {list(data.keys())}") print(f"Number of items: {len(data.get('items', []))}") print(f"Page: {data.get('page')}") print(f"Page size: {data.get('page_size')}") print(f"Total: {data.get('total')}") if data.get('items'): print(f"First item keys: {list(data['items'][0].keys())}") else: print(f"Error response: {response.text}") # Test with parameters params = { "customer_type": 1, "order_by": "project_name", "order_direction": "desc", "page": 1, "page_size": 5 } response2 = requests.get(f"{base_url}/api/v1/projects/", params=params) print(f"\nWith parameters - Status Code: {response2.status_code}") if response2.status_code == 200: data2 = response2.json() print(f"Filtered results - Total: {data2.get('total')}, Items: {len(data2.get('items', []))}") except requests.exceptions.ConnectionError: print("Server is not running on port 8001") except Exception as e: print(f"Error testing endpoint: {e}") if __name__ == "__main__": test_projects_list_endpoint()