seller_central_backend/test_registration.py

34 lines
1.2 KiB
Python
Raw Normal View History

import requests
phone = "9600494039"
# 1. Register
res = requests.post("http://localhost:8000/api/auth/register/", json={"phone": phone})
if res.status_code == 400 and "already exists" in res.text:
print("User already exists, logging in instead...")
res = requests.post("http://localhost:8000/api/auth/login/", json={"phone": phone})
else:
print("Register:", res.status_code, res.text)
# verify otp
res = requests.post("http://localhost:8000/api/auth/verify-otp/", json={"phone": phone, "otp": "123456"})
print("Verify:", res.status_code, res.text)
res = requests.post("http://localhost:8000/api/auth/login/", json={"phone": phone})
print("Login:", res.status_code, res.text)
token = res.json().get('access')
# 2. Update Profile
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
payload = {
"is_profile_complete": True,
"business_type": "individual_maker",
"store_slug": "heritage-crafts-9600",
"street": "123 Test Street",
"city": "Test City",
"state": "Test State",
"pincode": "123456",
"store_name": "Heritage Crafts"
}
res = requests.put("http://localhost:8000/api/profile/", headers=headers, json=payload)
print("Update:", res.status_code, res.text)