-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_backend_empty_folder.py
More file actions
38 lines (32 loc) · 1.35 KB
/
test_backend_empty_folder.py
File metadata and controls
38 lines (32 loc) · 1.35 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
import requests
import json
def test_extraction_empty_folder():
url = "http://localhost:8000/api/extract"
# Test case: Empty folder path, but valid file path with addon name
payload = {
"folderPath": "",
"filePaths": ["account/models/account_move.py"]
}
try:
print(f"Sending request to {url} with empty folderPath...")
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.")
first_file = data['data'][0]
print(f"Folder Name: {first_file['folderName']}")
print(f"Path: {first_file['path']}")
if first_file['folderName'] == 'account':
print("PASS: Correctly inferred folder name.")
else:
print(f"FAIL: Incorrect folder name. Expected 'account', got '{first_file['folderName']}'")
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_empty_folder()