-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_simple_generation.py
More file actions
103 lines (82 loc) · 2.56 KB
/
Copy pathtest_simple_generation.py
File metadata and controls
103 lines (82 loc) · 2.56 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
"""
Simple test for sample data generation API
"""
import requests
import time
import json
API_BASE_URL = "http://localhost:8000"
TENANT_ID = "test-tenant"
def test_job_creation():
"""Test creating a sample data generation job"""
print("Testing job creation...")
request_data = {
"query": "create a small boutique store for handmade jewelry",
"options": {
"num_products": 2,
"num_categories": 1,
"include_variants": False,
"clear_existing": True,
"price_range": {"min": 25.0, "max": 100.0}
}
}
headers = {
"Content-Type": "application/json",
"X-Tenant-ID": TENANT_ID
}
try:
response = requests.post(
f"{API_BASE_URL}/internal/sample-data/generate",
json=request_data,
headers=headers,
timeout=10
)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
if response.status_code == 200:
data = response.json()
job_id = data.get("job_id")
print(f"✅ Job created successfully: {job_id}")
return job_id
else:
print(f"❌ Job creation failed: {response.status_code}")
print(f"Error: {response.text}")
return None
except Exception as e:
print(f"❌ Request failed: {e}")
return None
def test_job_status(job_id):
"""Test getting job status"""
if not job_id:
return False
print(f"\nTesting job status for {job_id}...")
headers = {"X-Tenant-ID": TENANT_ID}
try:
response = requests.get(
f"{API_BASE_URL}/internal/sample-data/jobs/{job_id}",
headers=headers,
timeout=10
)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.text}")
if response.status_code == 200:
data = response.json()
print(f"✅ Job status retrieved: {data.get('status')}")
return True
else:
print(f"❌ Job status failed: {response.status_code}")
return False
except Exception as e:
print(f"❌ Status request failed: {e}")
return False
def main():
print("Simple Sample Data Generation Test")
print("==================================")
# Test 1: Create job
job_id = test_job_creation()
# Test 2: Check status
if job_id:
test_job_status(job_id)
print("\nTest completed!")
if __name__ == "__main__":
main()