diff --git a/api_helpers.py b/api_helpers.py index 62f6f0db..f24f63be 100644 --- a/api_helpers.py +++ b/api_helpers.py @@ -1,6 +1,6 @@ import requests -base_url = 'http://localhost:5000' +base_url = 'http://127.0.01:5001' # GET requests def get_api_data(endpoint, params = {}): diff --git a/app.py b/app.py index 1925371f..962e08d5 100644 --- a/app.py +++ b/app.py @@ -167,4 +167,4 @@ def patch(self, order_id): return {"message": "Order and pet status updated successfully"} if __name__ == '__main__': - app.run(debug=True) + app.run(host='127.0.0.1', port=5001, debug=True) 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..d21842f4 100644 --- a/test_pet.py +++ b/test_pet.py @@ -16,6 +16,7 @@ def test_pet_schema(): assert response.status_code == 200 + # Fix Schema was having name as integer instead of string, so fixed that in schemas.py # Validate the response schema against the defined schema in schemas.py validate(instance=response.json(), schema=schemas.pet) @@ -26,7 +27,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,7 +35,8 @@ def test_find_by_status_200(status): } response = api_helpers.get_api_data(test_endpoint, params) - # TODO... + # Fix of 2 Validate response code + assert_that(response.status_code, is_(200)) ''' TODO: Finish this test by... @@ -42,5 +44,9 @@ def test_find_by_status_200(status): 2) Parameterizing the test for any edge cases ''' def test_get_by_id_404(): - # TODO... - pass \ No newline at end of file + # Parameterize the test for edge cases such as negative numbers, very large numbers, etc. + for pet_id in [-1, 999999]: + test_endpoint = f"/pets/{pet_id}" + print(f"Testing endpoint: {test_endpoint}") + response = api_helpers.get_api_data(test_endpoint) + assert_that(response.status_code, is_(404)) \ No newline at end of file