Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api_helpers.py
Original file line number Diff line number Diff line change
@@ -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 = {}):
Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "integer"
},
"name": {
"type": "integer"
"type": "string"
},
"type": {
"type": "string",
Expand Down
14 changes: 10 additions & 4 deletions test_pet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -26,21 +27,26 @@ 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 = {
"status": 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...
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
# 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))