simondh commited on
Commit
85fced4
·
1 Parent(s): 49520a1

enhance tests

Browse files
Files changed (1) hide show
  1. test_server.py +17 -23
test_server.py CHANGED
@@ -14,33 +14,27 @@ def test_classify_text():
14
  emails.append(row)
15
 
16
  # Test with default categories using email content
17
- email = emails[0] # First email
18
- response = requests.post(
19
- f"{BASE_URL}/classify",
20
- json={"text": email["contenu"]}
21
- )
22
- print(f"Classification of email '{email['sujet']}' with default categories:")
23
- print(json.dumps(response.json(), indent=2))
24
 
25
- # Test with custom categories using another email
26
- email = emails[2] # Third email
27
- response = requests.post(
28
- f"{BASE_URL}/classify",
29
- json={
30
- "text": email["contenu"],
31
- "categories": ["Urgent", "Technique", "Commercial", "Personnel"]
32
- }
33
- )
34
- print(f"\nClassification of email '{email['sujet']}' with custom categories:")
35
- print(json.dumps(response.json(), indent=2))
36
 
37
  def test_suggest_categories():
38
- texts = [
39
- "This is a text about artificial intelligence and machine learning.",
40
- "A new breakthrough in quantum computing has been announced.",
41
- "The latest smartphone features innovative camera technology."
42
- ]
 
 
 
43
 
 
 
44
  response = requests.post(
45
  f"{BASE_URL}/suggest-categories",
46
  json=texts
 
14
  emails.append(row)
15
 
16
  # Test with default categories using email content
17
+ for email in emails[:5]:
18
+ response = requests.post(
19
+ f"{BASE_URL}/classify",
20
+ json={"text": email["contenu"]}
21
+ )
22
+ print(f"Classification of email '{email['sujet']}' with default categories:")
23
+ print(json.dumps(response.json(), indent=2))
24
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  def test_suggest_categories():
27
+ # Load reviews from CSV file
28
+ import csv
29
+
30
+ texts = []
31
+ with open("examples/reviews.csv", "r", encoding="utf-8") as file:
32
+ reader = csv.DictReader(file)
33
+ for row in reader:
34
+ texts.append(row["text"])
35
 
36
+ # Use the first few reviews for testing
37
+ texts = texts[:5]
38
  response = requests.post(
39
  f"{BASE_URL}/suggest-categories",
40
  json=texts