Repository navigation
Expand file tree
/
Copy pathtest_api_direct.py
More file actions
64 lines (54 loc) · 1.74 KB
/
Copy pathtest_api_direct.py
File metadata and controls
64 lines (54 loc) · 1.74 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
"""Simple test to see actual response data."""
import json
import requests
import subprocess
import time
import signal
import os
from contextlib import contextmanager
@contextmanager
def dev_server():
"""Start and stop the dev server."""
# Start the development server
proc = subprocess.Popen([
"/Users/ggbetz/.local/bin/uv", "run", "python", "-m",
"argdown_feedback.api.server.dev_server"
], cwd="/Users/ggbetz/git/argdown-feedback")
# Give it time to start
time.sleep(3)
try:
yield "http://localhost:8000"
finally:
# Kill the server
proc.terminate()
try:
proc.wait(timeout=5)
except subprocess.TimeoutExpired:
proc.kill()
def test_verifier():
with dev_server() as base_url:
# Test data
invalid_support_ref_xml = """
<proposition id="1">We should stop eating meat.</proposition>
<proposition id="2" supports="3">Animals suffer.</proposition>
"""
arganno_source_text = "We should stop eating meat. Animals suffer. Some animals are raised humanely."
# Make API request
response = requests.post(
f"{base_url}/api/v1/verify/arganno",
json={
"inputs": invalid_support_ref_xml,
"source": arganno_source_text,
"config": {}
}
)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
print(f"Response data:")
print(json.dumps(data, indent=2))
else:
print(f"Error: {response.text}")
if __name__ == "__main__":
test_verifier()