diff --git a/schemas.py b/schemas.py index 946cb6c..f6dcaac 100644 --- a/schemas.py +++ b/schemas.py @@ -6,7 +6,7 @@ "type": "integer" }, "name": { - "type": "integer" + "type": "string" }, "type": { "type": "string", @@ -18,3 +18,16 @@ }, } } + +order = { + "type": "object", + "required": ["id", "pet_id"], + "properties": { + "id": { + "type": "string" + }, + "pet_id": { + "type": "integer" + }, + } +} diff --git a/test_pet.py b/test_pet.py index e215678..aeb4b76 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 = { @@ -36,6 +36,12 @@ def test_find_by_status_200(status): response = api_helpers.get_api_data(test_endpoint, params) # TODO... + assert response.status_code == 200 + + for pet in response.json(): + assert pet["status"] in ["available", "sold", "pending"] + validate(instance=pet, schema=schemas.pet) + ''' TODO: Finish this test by... 1) Testing and validating the appropriate 404 response for /pets/{pet_id} @@ -43,4 +49,8 @@ def test_find_by_status_200(status): ''' def test_get_by_id_404(): # TODO... - pass \ No newline at end of file + test_endpoint = "/pets/-1" + + response = api_helpers.get_api_data(test_endpoint) + + assert response.status_code == 404 \ No newline at end of file diff --git a/test_store.py b/test_store.py index 186bd79..9e70774 100644 --- a/test_store.py +++ b/test_store.py @@ -13,4 +13,17 @@ 4) Validate the response message "Order and pet status updated successfully" ''' def test_patch_order_by_id(): - pass + + post_endpoint = f"/store/order/" + + post_response = api_helpers.post_api_data(endpoint=post_endpoint, data={ + "pet_id": 0 + }) + + patch_endpoint = "/store/order/0" + patch_response = api_helpers.patch_api_data(endpoint=patch_endpoint, data={ + "status": "available", + "id": 0 + }) + + assert patch_response.message == "Order and pet status updated successfully"