File size: 1,699 Bytes
da3e674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Direct debug of _http_get"""
import sys, os
project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if project_root not in sys.path:
    sys.path.insert(0, project_root)

import asyncio
import requests
from space.eu_gaia_x_adapter import EUGaiaXAdapter

async def main():
    a = EUGaiaXAdapter()
    
    # Test 1: URL with inline params (like health_check)
    print("Test 1: URL with inline params")
    url1 = "https://api.openaire.eu/search/publications?format=json&size=2&title=climate"
    try:
        d1 = await a._http_get(url1, timeout=15)
        print(f"  type={type(d1)}, is_none={d1 is None}")
        if isinstance(d1, dict):
            print(f"  keys={list(d1.keys())}")
    except Exception as e:
        print(f"  EXCEPTION: {e}")

    # Test 2: URL + params dict (like query_openaire)
    print("\nTest 2: URL + params dict")
    url2 = "https://api.openaire.eu/search/publications"
    params2 = {"format": "json", "size": 2, "title": "climate"}
    try:
        d2 = await a._http_get(url2, params=params2, timeout=15)
        print(f"  type={type(d2)}, is_none={d2 is None}")
        if isinstance(d2, dict):
            print(f"  keys={list(d2.keys())}")
    except Exception as e:
        print(f"  EXCEPTION: {e}")

    # Test 3: Direct requests call
    print("\nTest 3: Direct requests.get")
    try:
        r = requests.get(url2, params=params2, timeout=15)
        print(f"  status={r.status_code}, url={r.url}")
        d3 = r.json()
        print(f"  type={type(d3)}, keys={list(d3.keys())}")
    except Exception as e:
        print(f"  EXCEPTION: {e}")

    await a.close()

asyncio.run(main())