From ed16c2ff240ea4db76b832723d56991be9154bae Mon Sep 17 00:00:00 2001 From: venkatachandraminnikanti-eng Date: Wed, 5 Nov 2025 15:58:56 -0500 Subject: [PATCH 1/5] Venkata --- Bug_Report.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Bug_Report.txt diff --git a/Bug_Report.txt b/Bug_Report.txt new file mode 100644 index 0000000..e69de29 From f2114ee05a376d84304aecb33f4b93e1f94d9fd6 Mon Sep 17 00:00:00 2001 From: venkatachandraminnikanti-eng Date: Wed, 5 Nov 2025 16:07:27 -0500 Subject: [PATCH 2/5] Change 'name' type to string and add 'order' schema --- schemas.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/schemas.py b/schemas.py index 946cb6c..43e15d5 100644 --- a/schemas.py +++ b/schemas.py @@ -6,7 +6,7 @@ "type": "integer" }, "name": { - "type": "integer" + "type": "string" }, "type": { "type": "string", @@ -18,3 +18,24 @@ }, } } + +order = { + "type": "object", + "required": ["pet_id"], + "properties": { + "id": { + "type": "string" + }, + "pet_id": { + "type": "integer" + }, + "status": { + "type": "string", + "enum": ["placed", "approved", "delivered", "cancelled", "sold"] + }, + "complete": { + "type": "boolean" + } + }, + "additionalProperties": True +} From 92ec8a8be68b0c0e7e0e004c03765e5e4450bc67 Mon Sep 17 00:00:00 2001 From: venkatachandraminnikanti-eng Date: Wed, 5 Nov 2025 16:09:44 -0500 Subject: [PATCH 3/5] Enhance pet API tests with schema validation and params Updated tests to validate response schema and added parameterization for status and pet_id. --- test_pet.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/test_pet.py b/test_pet.py index e215678..bc94561 100644 --- a/test_pet.py +++ b/test_pet.py @@ -16,7 +16,7 @@ def test_pet_schema(): assert response.status_code == 200 - # Validate the response schema against the defined schema in schemas.py + validate(instance=response.json(), schema=schemas.pet) ''' @@ -26,7 +26,7 @@ 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")]) +@pytest.mark.parametrize("status", ["available", "sold", "pending"]) def test_find_by_status_200(status): test_endpoint = "/pets/findByStatus" params = { @@ -34,13 +34,33 @@ def test_find_by_status_200(status): } response = api_helpers.get_api_data(test_endpoint, params) - # TODO... + assert response.status_code == 200 + + + pets = response.json() + for pet in pets: + + validate(instance=pet, schema=schemas.pet) + + assert_that(pet.get("status"), is_(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", [-1, 999999, 0.5]) +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 + + try: + response_data = response.json() + if isinstance(response_data, dict): + error_msg = response_data.get("message", "") + assert "Pet not found" in error_msg or f"Pet with ID {pet_id}" in error_msg + except ValueError: + + pass From 639bd6fee024f649130bde548f2f4d0ba684f492 Mon Sep 17 00:00:00 2001 From: venkatachandraminnikanti-eng Date: Wed, 5 Nov 2025 16:10:46 -0500 Subject: [PATCH 4/5] Implement order creation and patch tests Added a fixture to create an order and validate its response. Implemented a test to patch an order by ID and verify the status update. --- test_store.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/test_store.py b/test_store.py index 186bd79..853cf46 100644 --- a/test_store.py +++ b/test_store.py @@ -12,5 +12,39 @@ 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.fixture +def create_order(): + order_payload = { + "pet_id": 0, + "complete": False + } + + response = api_helpers.post_api_data("/store/order", order_payload) + if response.status_code != 201: + pytest.fail(f"Failed to create order. Status: {response.status_code}, Response: {response.text}, Headers: {response.headers}") + + order = response.json() + assert isinstance(order, dict), f"Expected dict response, got {type(order)}" + assert "id" in order, f"Order response missing 'id' field: {order}" + assert "pet_id" in order, f"Order response missing 'pet_id' field: {order}" + + validate(instance=order, schema=schemas.order) + yield order + +def test_patch_order_by_id(create_order): + order = create_order + assert "id" in order, "Order fixture did not return required 'id' field" + order_id = order["id"] + + patch_payload = { + "status": "sold", + "pet_id": order["pet_id"] + } + response = api_helpers.patch_api_data(f"/store/order/{order_id}", patch_payload) + + assert response.status_code == 200 + assert_that(response.json().get("message"), is_("Order and pet status updated successfully")) + + pet_response = api_helpers.get_api_data(f"/pets/{order['pet_id']}") + assert pet_response.status_code == 200 + assert_that(pet_response.json().get("status"), is_("sold")) From 783f3d500f7bc82251df135bf6608edfee84b33d Mon Sep 17 00:00:00 2001 From: venkatachandraminnikanti-eng Date: Wed, 5 Nov 2025 16:11:22 -0500 Subject: [PATCH 5/5] Add bug report with encountered issues and solutions Documented various bugs encountered and their respective solutions in the API. --- Bug_Report.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Bug_Report.txt b/Bug_Report.txt index e69de29..db16a13 100644 --- a/Bug_Report.txt +++ b/Bug_Report.txt @@ -0,0 +1,22 @@ + Bugs Encountered and Solutions +First_Bug: In schemas.py, the “name” field was set as an integer +First_Solution: API actually returns it as a string. I updated the schema to match the API. + +Second_Bug: Schema validation errors due to missing required fields and incorrect field types +Second_Solution: Updated order schema to: + Make status field optional + Handle UUID strings for order IDs + Allow additional properties + +Third_Bug: Different response formats (HTML vs JSON) for invalid pet IDs (-1, 999999, 0.5) +Third_Solution: Added better error handling in tests to support both content types + +Fourth_Bug: Unable to verify order updates due to missing GET endpoint for /store/order/{order_id} +Fourth_Solution: Implemented alternative validation by checking pet status instead + + +Fifth_Bug: In-memory data causing test interference when updating pet statuses +Fifth_Solution: Implemented fixture create_order to ensure fresh test data for each run + +Sixth_Bug: PATCH requests failing due to missing required fields +Sixth_Solution: Include pet_id in PATCH payload to maintain data integrity