From c3674735963586eaad20a089720714a750ec49c7 Mon Sep 17 00:00:00 2001 From: tejaswini-qadev Date: Tue, 24 Mar 2026 23:51:01 -0400 Subject: [PATCH 1/2] fix tests --- schemas.py | 2 +- test_pet.py | 41 ++++++++++++++++++++++++++++++++++++----- test_store.py | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 67 insertions(+), 8 deletions(-) diff --git a/schemas.py b/schemas.py index 946cb6cc..760be600 100644 --- a/schemas.py +++ b/schemas.py @@ -6,7 +6,7 @@ "type": "integer" }, "name": { - "type": "integer" + "type": "string" }, "type": { "type": "string", diff --git a/test_pet.py b/test_pet.py index e2156781..c83b12c4 100644 --- a/test_pet.py +++ b/test_pet.py @@ -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) @@ -26,7 +31,8 @@ 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 = { @@ -34,13 +40,38 @@ def test_find_by_status_200(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 \ No newline at end of file +@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 + diff --git a/test_store.py b/test_store.py index 186bd792..8aa26249 100644 --- a/test_store.py +++ b/test_store.py @@ -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"] From cfede08e796b544b9cef6e9714e3df81381c183e Mon Sep 17 00:00:00 2001 From: tejaswini-qadev Date: Wed, 25 Mar 2026 00:20:45 -0400 Subject: [PATCH 2/2] add bug summary file --- SUMMARY.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 SUMMARY.md diff --git a/SUMMARY.md b/SUMMARY.md new file mode 100644 index 00000000..2b7d56a7 --- /dev/null +++ b/SUMMARY.md @@ -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 + +--- \ No newline at end of file