-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_backend.py
More file actions
49 lines (41 loc) · 1.79 KB
/
Copy pathtest_backend.py
File metadata and controls
49 lines (41 loc) · 1.79 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
import requests
import json
def test_extraction():
url = "http://localhost:8000/api/extract"
payload = {
"folderPath": "account",
"filePaths": ["models/account_move.py"]
}
try:
print(f"Sending request to {url}...")
response = requests.post(url, json=payload, timeout=30)
print(f"Status Code: {response.status_code}")
if response.status_code == 200:
data = response.json()
if data.get('success'):
print(f"Success! Extracted {len(data['data'])} files.")
print(f"First file: {data['data'][0]['path']}")
# Test Markdown Generation
print("\nTesting Markdown Generation...")
md_url = "http://localhost:8000/api/generate-markdown"
md_payload = {"files": data['data']}
md_response = requests.post(md_url, json=md_payload, timeout=30)
print(f"Markdown Status Code: {md_response.status_code}")
if md_response.status_code == 200:
md_data = md_response.json()
if md_data.get('success'):
print("Markdown Generation Success!")
print("Preview (first 500 chars):")
print(md_data['markdown'][:500])
else:
print(f"Markdown Failed: {md_data.get('error')}")
else:
print(f"Markdown Error: {md_response.text}")
else:
print(f"Failed: {data.get('error')}")
else:
print(f"Error: {response.text}")
except Exception as e:
print(f"Exception: {e}")
if __name__ == "__main__":
test_extraction()