test: add utility scripts for testing registration and profile updates
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 37s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 37s
This commit is contained in:
parent
287b0e769e
commit
b7dac2f02d
3 changed files with 48 additions and 0 deletions
8
get_columns.py
Normal file
8
get_columns.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import os
|
||||
import django
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
django.setup()
|
||||
|
||||
from api.models import SupplierProfile
|
||||
columns = [f.name for f in SupplierProfile._meta.get_fields()]
|
||||
print("Columns:", columns)
|
||||
7
test_profile_update.py
Normal file
7
test_profile_update.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import os
|
||||
import django
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||
django.setup()
|
||||
|
||||
from api.models import SupplierProfile
|
||||
print("Supplier Profiles:", list(SupplierProfile.objects.all().values()))
|
||||
33
test_registration.py
Normal file
33
test_registration.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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)
|
||||
Loading…
Reference in a new issue