Skip to content

Commit 2d948eb

Browse files
authored
Adding tests for object client
1 parent e1adca2 commit 2d948eb

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

tests/e2e/test_e2e_user_flow.py

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
1+
# Validating response data for vehicles API
22
def test_create_and_get_carmakes(client):
33

44
get_response = client.get("/getallmakes?format=json")
55
assert get_response.status_code == 200
66
api_response = get_response.json()
77
assert api_response['Message'] == "Response returned successfully"
8-
assert api_response['Results'][2]['Make_Name'] == '102 IRONWORKS, INC.' # Print first 100 results for brevity
9-
10-
8+
assert api_response['Results'][2]['Make_Name'] == '102 IRONWORKS, INC.' # Print first 100 results for brevity
119

1210
def test_create_and_get_manufacturers(client):
1311

@@ -17,5 +15,48 @@ def test_create_and_get_manufacturers(client):
1715
assert api_response['Message'] == "Response returned successfully" # validate the message
1816
assert api_response['Results'][0]['Country'] in ["UNITED STATES (USA)", "JAPAN", "MEXICO"] # validate the country
1917
assert api_response['Results'][0]['VehicleTypes'] is not [] #validate the vehicle types are not empty
20-
18+
19+
20+
# Validating response data for Objects API
21+
def test_create_and_get_objects(client_object):
22+
23+
get_response = client_object.get("/objects")
24+
assert get_response.status_code == 200
25+
api_response = get_response.json()
26+
assert api_response[0]['id'] == "1" #validate ID
27+
assert api_response[0]['data']['color'] == "Cloudy White"
28+
assert api_response[1]['data'] is None #validate data object
29+
30+
31+
def test_create_and_get_specific_objects(client_object):
32+
33+
get_response = client_object.get("/objects?id=2&id=4&id=7")
34+
assert get_response.status_code == 200
35+
api_response = get_response.json()
36+
assert api_response[0]['id'] == "2" #validate the first object ID
37+
assert api_response[1]['id'] == "4" #validate the second object ID
38+
assert api_response[2]['id'] == "7" #validate the third object ID
39+
assert api_response[0]['data'] is None #validate the first object data is None
40+
assert api_response[1]['data'] is not None #validate the second object data is not None
41+
42+
43+
def test_create_and_post_object(client_object):
44+
45+
post_data = {
46+
"name": "Apple Pro",
47+
"data": {
48+
"year": 2025,
49+
"price": 2049.99,
50+
"CPU model": "Intel Core i9",
51+
"Hard disk size": "1 TB"
52+
},
53+
}
54+
55+
post_response = client_object.post("/objects", json=post_data)
56+
assert post_response.status_code == 200
57+
api_response = post_response.json()
58+
#validating the response data
59+
assert api_response['name'] == "Apple Pro"
60+
assert api_response['data']['year'] == 2025
61+
assert api_response['data']['price'] == 2049.99
2162

0 commit comments

Comments
 (0)