-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
35 lines (26 loc) · 1002 Bytes
/
test.py
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
34
import pytest
import requests
@pytest.mark.parametrize("user_id, expected_email", [
(2, "[email protected]"),
])
def test_user_data(user_id, expected_email):
# url = f"https://reqres.in/api/users/{user_id}"
url = f"http://0.0.0.0:8000/api/users/{user_id}"
response = requests.get(url)
assert response.status_code == 200, f"Expected status code 200, but got {response.status_code}"
body = response.json()
assert "data" in body, "Response body does not contain 'data' key"
data = body["data"]
assert data["id"] == user_id, f"Expected id {user_id}, but got {data['id']}"
assert data["email"] == expected_email, f"Expected email {expected_email}, but got {data['email']}"
# def test_user_data():
# url = "https://reqres.in/api/users/2"
# id = 2
# email = "[email protected]"
#
# response = requests.get(url)
# body = response.json()
# data = body["data"]
#
# assert data["id"] == id
# assert data["email"] == email