-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_api.py
More file actions
35 lines (29 loc) · 1.01 KB
/
test_api.py
File metadata and controls
35 lines (29 loc) · 1.01 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
"""Test script for backend API"""
import requests
import json
# Test 1: Dark pattern example
print("[TEST 1] Testing dark pattern detection...")
response = requests.post(
"http://localhost:8000/analyze",
json={
"text": "WARNING! Last chance! Only 2 items left at this price. 127 people are viewing. Book now!",
"buttons": ["Accept Now", "Maybe Later"]
}
)
print(f"Status Code: {response.status_code}")
print(f"Response:")
print(json.dumps(response.json(), indent=2))
print("\n" + "="*60 + "\n")
# Test 2: Ethical example
print("[TEST 2] Testing ethical UI...")
response2 = requests.post(
"http://localhost:8000/analyze",
json={
"text": "Cookie Preferences: You can Accept All, Reject All, or Customize your preferences. You can change these settings anytime.",
"buttons": ["Accept All", "Reject All", "Customize"]
}
)
print(f"Status Code: {response2.status_code}")
print(f"Response:")
print(json.dumps(response2.json(), indent=2))
print("\n[OK] Backend API tests complete!")