-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick_test.py
More file actions
63 lines (50 loc) · 1.91 KB
/
Copy pathquick_test.py
File metadata and controls
63 lines (50 loc) · 1.91 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
#!/usr/bin/env python3
import requests
import json
import time
def test_pdf_conversion():
"""Quick test of PDF conversion endpoint"""
# Simple test content
test_content = """
# Test Document
This is a **test document** with some basic formatting.
## Features
- Item 1
- Item 2
> This is a blockquote
"""
# Test data
test_data = {
"content": test_content,
"content_type": "markdown",
"priority": "auto"
}
try:
print("Testing PDF conversion endpoint...")
response = requests.post(
"http://localhost:8005/convert-to-pdf",
json=test_data,
timeout=30
)
if response.status_code == 200:
print("✓ PDF conversion successful!")
print(f" - Content-Type: {response.headers.get('content-type', 'unknown')}")
print(f" - PDF Size: {len(response.content)} bytes")
print(f" - Converter Used: {response.headers.get('X-Converter-Used', 'unknown')}")
print(f" - Processing Time: {response.headers.get('X-Processing-Time', 'unknown')}s")
print(f" - Complexity Detected: {response.headers.get('X-Complexity-Detected', 'unknown')}")
# Save the PDF
with open("test_output.pdf", "wb") as f:
f.write(response.content)
print(" - PDF saved as 'test_output.pdf'")
else:
print(f"✗ PDF conversion failed with status {response.status_code}")
print(f" Error: {response.text}")
except requests.exceptions.ConnectionError:
print("✗ Cannot connect to server. Please make sure the server is running on port 8005.")
except requests.exceptions.Timeout:
print("✗ Request timed out")
except Exception as e:
print(f"✗ Unexpected error: {e}")
if __name__ == "__main__":
test_pdf_conversion()