Spaces:
Sleeping
Sleeping
Upload test_categories_api.py
Browse files- test_categories_api.py +23 -0
test_categories_api.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
def test_categories():
|
| 5 |
+
base_url = "http://localhost:8000/api"
|
| 6 |
+
try:
|
| 7 |
+
response = requests.get(f"{base_url}/categories")
|
| 8 |
+
if response.status_code == 200:
|
| 9 |
+
data = response.json()
|
| 10 |
+
if data['isSuccess']:
|
| 11 |
+
items = data['value']['items']
|
| 12 |
+
print(f"Total categories returned: {len(items)}")
|
| 13 |
+
for item in items:
|
| 14 |
+
print(f"- {item['name_en']} (ID: {item['id']}, Parent: {item['parent_id']})")
|
| 15 |
+
else:
|
| 16 |
+
print(f"API Error: {data['error']}")
|
| 17 |
+
else:
|
| 18 |
+
print(f"HTTP Error: {response.status_code}")
|
| 19 |
+
except Exception as e:
|
| 20 |
+
print(f"Connection Error: {e}")
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
test_categories()
|