Files
avaair-e2e-tests/tests/test_get_customer_profile.py
Reza Esmaeili 9e69b14249 Init commit
2025-12-04 12:46:23 +03:30

48 lines
1.6 KiB
Python

import requests
import pytest
from conftest import BASE_URL
def test_customer_profile_basic(auth_header, customer_auth):
"""
Validate basic customer profile integrity.
Scenario:
• Perform GET /customer/profile using the authenticated user context.
• Assert HTTP 200 success.
• Validate presence of essential profile fields (id, username, mobile_number).
• Cross-check that returned values match the authenticated user (from OTP login).
"""
print("\n[PROFILE] Fetching customer profile ...")
res = requests.get(
f"{BASE_URL}/customer/profile",
headers=auth_header,
timeout=10,
)
assert res.status_code == 200, "Expected HTTP 200 for /customer/profile"
data = res.json()
# Required fields that must always exist in the profile schema
required_fields = ["id", "username", "mobile_number"]
for key in required_fields:
assert key in data, f"Missing expected field '{key}' in /customer/profile response"
# Structural consistency:
# Ensure that the profile returned for this token belongs to the same user
# who successfully passed OTP authentication.
assert data["id"] == customer_auth["user"]["id"], (
"Profile 'id' does not match authenticated user id"
)
assert data["mobile_number"] == customer_auth["user"]["mobile_number"], (
"Profile 'mobile_number' does not match authenticated user mobile_number"
)
print(
f"[PROFILE] Profile validated successfully. "
f"User: {data['username']} (id={data['id']})\n"
)