forked from automationExamples/pytest-api-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_store.py
More file actions
33 lines (28 loc) · 1.12 KB
/
test_store.py
File metadata and controls
33 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from jsonschema import validate
import pytest
import schemas
import api_helpers
from hamcrest import assert_that, contains_string, is_
'''
TODO: Finish this test by...
1) Creating a function to test the PATCH request /store/order/{order_id}
2) *Optional* Consider using @pytest.fixture to create unique test data for each run
2) *Optional* Consider creating an 'Order' model in schemas.py and validating it in the test
3) Validate the response codes and values
4) Validate the response message "Order and pet status updated successfully"
'''
def test_patch_order_by_id():
# 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]