-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_validation.py
More file actions
43 lines (34 loc) · 1.8 KB
/
Copy pathdebug_validation.py
File metadata and controls
43 lines (34 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys
sys.path.append('src')
import httpx
import asyncio
from pharmacology_mcp.pharmacology_api import LigandResponse
async def test_validation():
# Get real data from the API
async with httpx.AsyncClient() as client:
try:
response = await client.get("https://www.guidetopharmacology.org/services/ligands", timeout=10)
print(f"External API Status: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(f"External API returned {len(data)} ligands")
if data:
first_ligand = data[0]
print(f"First ligand raw data: {first_ligand}")
# Try to validate it
try:
validated = LigandResponse.model_validate(first_ligand)
print(f"Validation successful: {validated}")
except Exception as e:
print(f"Validation error: {e}")
print(f"Error type: {type(e)}")
# Check what fields are missing or wrong
expected_fields = LigandResponse.model_fields.keys()
actual_fields = first_ligand.keys()
print(f"Expected fields: {list(expected_fields)}")
print(f"Actual fields: {list(actual_fields)}")
print(f"Missing fields: {set(expected_fields) - set(actual_fields)}")
print(f"Extra fields: {set(actual_fields) - set(expected_fields)}")
except Exception as e:
print(f"External API Error: {e}")
asyncio.run(test_validation())