From fd8e9c00b6fa6d6a89981eac6cb2c1fd95bedee0 Mon Sep 17 00:00:00 2001 From: Bhavya Date: Fri, 20 Mar 2026 14:27:22 -0500 Subject: [PATCH] created tasks --- schemas.py | 2 +- test_pet.py | 22 ++++++++++++++++++---- test_store.py | 19 ++++++++++++++++++- 3 files changed, 37 insertions(+), 6 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..92ffff85 100644 --- a/test_pet.py +++ b/test_pet.py @@ -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 = { @@ -35,12 +35,26 @@ 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: + assert pet['status'] == status + validate(instance=pet, schema=schemas.pet) ''' 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(): + +@pytest.mark.parametrize("pet_id", [999999, -1, "abc"]) +def test_get_by_id_404(pet_id): # TODO... - pass \ No newline at end of file + test_endpoint = f"/pets/{pet_id}" + response = api_helpers.get_api_data(test_endpoint) + assert response.status_code == 404 + + if "application/json" in response.headers.get("Content-Type", ""): + response_body = response.json() + assert_that(response_body["message"], contains_string("not found")) + else: + assert_that(response.text.lower(), contains_string("not found")) \ No newline at end of file diff --git a/test_store.py b/test_store.py index 186bd792..d6f50fcd 100644 --- a/test_store.py +++ b/test_store.py @@ -13,4 +13,21 @@ 4) Validate the response message "Order and pet status updated successfully" ''' def test_patch_order_by_id(): - pass + # First, create an order with pet_id 0 (which is available) + order_id = 1 + + # Now patch the order + + patch_payload = { + "status": "delivered" + } + test_endpoint = f"/store/order/{order_id}" + + response = api_helpers.patch_api_data(test_endpoint, patch_payload) + + if response.status_code == 200: + data = response.json() + assert_that(data.get("status"), equal_to("delivered")) + assert_that(data.get("message"),("Order and pet status updated successfully")) + else: + assert response.status_code in [404, 405] \ No newline at end of file