File size: 1,073 Bytes
e8ff22d
 
70ca2a3
e8ff22d
 
 
 
 
 
 
 
70ca2a3
e8ff22d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70ca2a3
 
e8ff22d
 
 
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
import requests

BASE_URL = "https://loren-api-search-articles.hf.space"

def test_get_tags():
    print("🔍 Test: /get_tags")
    resp = requests.get(f"{BASE_URL}/get_tags")
    if resp.status_code != 200:
        print("❌ Erreur", resp.status_code, resp.text)
        return
    tags = resp.json().get("tags", [])
    print(f"✅ {len(tags)} tags récupérés : {tags[:3]}...")  # affiche 3 premiers

    return tags

def test_get_articles_with_tags(tags):
    if not tags:
        print("⚠️ Aucun tag trouvé, test sauté")
        return

    print("\n🔍 Test: /get_articles_with_tags")
    params = {"tags": tags}
    resp = requests.get(f"{BASE_URL}/get_articles_with_tags", params=params)
    if resp.status_code != 200:
        print("❌ Erreur", resp.status_code, resp.text)
        return
    data = resp.json()
    print(f"✅ Articles trouvés: {len(data['articles'])}")

def main():
    tags = test_get_tags()
    print(tags[0:1])
    test_get_articles_with_tags(tags[0:1])

if __name__ == "__main__":
    main()