Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crud/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def create_customer(db: Session, customer: CustomerCreate) -> Customer:
raise HTTPException(status_code=400, detail={"errCode": 400, "errMsg": "Email already exists"})
hashed_password = get_password_hash(customer.password)
db_customer = Customer(**customer.dict(exclude={"password"}), hashed_password=hashed_password)
# Commit to db
db.add(db_customer)
db.commit()
db.refresh(db_customer)
Expand Down
35 changes: 35 additions & 0 deletions tests/customer/scrum-78.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pytest
import requests

@pytest.mark.parametrize("payload, expected_status, expected_response", [
(
{
"first_name": "John",
"last_name": "Doe",
"email": "invalid-email-format"
},
400,
{
"errorCode": "400",
"errorMsg": "Invalid email format"
}
)
])
def test_invalid_email_format(api_base_url, auth_token, payload, expected_status, expected_response):
url = f"{api_base_url}/customer/"
headers = {
"Authorization": f"Bearer {auth_token}",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

# Assert status code
assert response.status_code == expected_status, f"Expected {expected_status}, got {response.status_code}"

# Assert response schema
response_json = response.json()
assert response_json == expected_response, f"Expected {expected_response}, got {response_json}"

# Assert SLA
assert response.elapsed.total_seconds() <= 3, f"SLA exceeded: {response.elapsed.total_seconds()}s"