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
99 changes: 99 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Bug Report Summary

---

## BUG 1: Schema mismatch for `name` field

**Title:**
Schema validation failure due to incorrect data type for `name` field

**Module / Location:**
Pet API – `/pets/{pet_id}`
File: `schemas.py`

**Description:**
While validating the API response for `/pets/{pet_id}`, it was observed that the `name` field is defined as an integer in the schema, whereas the API returns it as a string (e.g., `"ranger"`). This mismatch causes schema validation to fail even though the API response is correct.

**Expected Result:**
The schema should define `name` as a string and validation should pass

**Actual Result:**
Schema expects integer → validation fails

**Impact:**
High – causes false negatives in automation tests

**Severity / Priority:**
Severity: High
Priority: High

**Suggested Fix:**
```python
"name": {
"type": "string"
}
```

---

## BUG 2: PATCH API does not return updated resource

**Title:**
PATCH endpoint does not return updated order or pet details

**Module / Location:**
Store API – `/store/order/{order_id}`

**Description:**
PATCH endpoint only returns a success message and does not include updated data, making validation difficult.

**Expected Result:**
Response should include updated order or pet details

**Actual Result:**
```json
{ "message": "Order and pet status updated successfully" }
```

**Impact:**
Medium – limits validation capability

---

## BUG 3: Inconsistent error response format

**Title:**
API returns inconsistent error response formats

**Description:**
Some error responses return JSON, while others return HTML (Flask default), causing parsing issues.

**Expected Result:**
Consistent JSON error response

**Actual Result:**
Mixed formats

**Impact:**
Medium – causes JSON parsing failures

---

## BUG 4: Invalid ID types not handled properly

**Title:**
Invalid data types for `pet_id` are not handled consistently

**Description:**
Non-integer inputs like `"abc"` or `None` do not reach API logic and return framework-level HTML responses.

**Expected Result:**
Return proper JSON error

**Actual Result:**
Returns HTML error page

**Impact:**
Medium – inconsistent API behavior

---
2 changes: 1 addition & 1 deletion schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "integer"
},
"name": {
"type": "integer"
"type": "string"
},
"type": {
"type": "string",
Expand Down
41 changes: 36 additions & 5 deletions test_pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ def test_pet_schema():

assert response.status_code == 200

data = response.json()

# Check if response is a dictionary
assert isinstance(data, dict)

# Validate the response schema against the defined schema in schemas.py
validate(instance=response.json(), schema=schemas.pet)

Expand All @@ -26,21 +31,47 @@ def test_pet_schema():
3) Validate the 'status' property in the response is equal to the expected status
4) Validate the schema for each object in the response
'''
@pytest.mark.parametrize("status", [("available")])
# 1) Extending the parameterization to include all available statuses
@pytest.mark.parametrize("status", ["available", "pending", "sold"])
def test_find_by_status_200(status):
test_endpoint = "/pets/findByStatus"
params = {
"status": status
}

response = api_helpers.get_api_data(test_endpoint, params)
# TODO...

# 2) Validate the response code
assert response.status_code == 200

data = response.json()

# Check if response is a list
assert isinstance(data, list)

for pet in data:
# 4) Validate the schema for each object in the response
validate(instance=pet, schema=schemas.pet)

# 3) Validate the 'status' property in the response is equal to the expected status
if "status" in pet:
assert pet["status"] == status

'''
TODO: Finish this test by...
1) Testing and validating the appropriate 404 response for /pets/{pet_id}
2) Parameterizing the test for any edge cases
'''
def test_get_by_id_404():
# TODO...
pass
@pytest.mark.parametrize("pet_id", [
"dog", # invalid type
1.0, # valid type but invalid value
10, # unknown id

])
def test_get_by_id_404(pet_id):
test_endpoint = f"/pets/{pet_id}"

response = api_helpers.get_api_data(test_endpoint)

assert response.status_code == 404

32 changes: 30 additions & 2 deletions test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,33 @@
3) Validate the response codes and values
4) Validate the response message "Order and pet status updated successfully"
'''
def test_patch_order_by_id():
pass

@pytest.mark.parametrize("pet_id", [0, 2]) # only available pets
def test_patch_order_by_id(pet_id):
# Step 1: Create an order first (required for PATCH)
order_payload = {
"pet_id": pet_id # must be an 'available' pet
}

order_response = api_helpers.post_api_data("/store/order", order_payload)
assert order_response.status_code == 201

order_data = order_response.json()
order_id = order_data["id"]

# Step 2: PATCH the order
patch_payload = {
"status": "sold"
}

patch_endpoint = f"/store/order/{order_id}"
patch_response = api_helpers.patch_api_data(patch_endpoint, patch_payload)

# Step 3: Validate response
assert patch_response.status_code == 200

data = patch_response.json()

# Validate message (ONLY thing returned)
assert "message" in data
assert "updated successfully" in data["message"]