diff options
Diffstat (limited to '')
| -rw-r--r-- | tests/__pycache__/test_api_edge.cpython-314-pytest-9.0.3.pyc | bin | 0 -> 6483 bytes | |||
| -rw-r--r-- | tests/__pycache__/test_api_get.cpython-314-pytest-9.0.3.pyc | bin | 0 -> 5897 bytes | |||
| -rw-r--r-- | tests/__pycache__/test_api_post.cpython-314-pytest-9.0.3.pyc | bin | 0 -> 5335 bytes | |||
| -rw-r--r-- | tests/test_api_edge.py | 24 | ||||
| -rw-r--r-- | tests/test_api_get.py | 22 | ||||
| -rw-r--r-- | tests/test_api_post.py | 21 |
6 files changed, 67 insertions, 0 deletions
diff --git a/tests/__pycache__/test_api_edge.cpython-314-pytest-9.0.3.pyc b/tests/__pycache__/test_api_edge.cpython-314-pytest-9.0.3.pyc Binary files differnew file mode 100644 index 0000000..00cbab5 --- /dev/null +++ b/tests/__pycache__/test_api_edge.cpython-314-pytest-9.0.3.pyc diff --git a/tests/__pycache__/test_api_get.cpython-314-pytest-9.0.3.pyc b/tests/__pycache__/test_api_get.cpython-314-pytest-9.0.3.pyc Binary files differnew file mode 100644 index 0000000..df08795 --- /dev/null +++ b/tests/__pycache__/test_api_get.cpython-314-pytest-9.0.3.pyc diff --git a/tests/__pycache__/test_api_post.cpython-314-pytest-9.0.3.pyc b/tests/__pycache__/test_api_post.cpython-314-pytest-9.0.3.pyc Binary files differnew file mode 100644 index 0000000..bf37370 --- /dev/null +++ b/tests/__pycache__/test_api_post.cpython-314-pytest-9.0.3.pyc diff --git a/tests/test_api_edge.py b/tests/test_api_edge.py index e69de29..f663834 100644 --- a/tests/test_api_edge.py +++ b/tests/test_api_edge.py @@ -0,0 +1,24 @@ +import requests + +BASE = "https://jsonplaceholder.typicode.com" + +def test_get_posts_filter_by_userid(): + r = requests.get(f"{BASE}/posts?userId=1") + assert r.status_code == 200 + for post in r.json(): + assert post["userId"] == 1 + +def test_patch_post_partial_update(): + payload = {"title": "updated by qa"} + r = requests.patch(f"{BASE}/posts/1", json=payload) + assert r.status_code == 200 + assert r.json()["title"] == "updated by qa" + +def test_delete_post_status_200(): + r = requests.delete(f"{BASE}/posts/1") + assert r.status_code == 200 + +def test_get_comments_by_postid(): + r = requests.get(f"{BASE}/comments?postId=1") + assert r.status_code == 200 + assert len(r.json()) > 0 diff --git a/tests/test_api_get.py b/tests/test_api_get.py index e69de29..1e900a8 100644 --- a/tests/test_api_get.py +++ b/tests/test_api_get.py @@ -0,0 +1,22 @@ +import requests + +BASE = "https://jsonplaceholder.typicode.com" + +def test_get_users_status_200(): + r = requests.get(f"{BASE}/users") + assert r.status_code == 200 + +def test_get_users_has_data(): + r = requests.get(f"{BASE}/users") + body = r.json() + assert isinstance(body, list) + assert len(body) > 0 + +def test_get_single_user_status_200(): + r = requests.get(f"{BASE}/users/1") + assert r.status_code == 200 + assert r.json()["id"] == 1 + +def test_get_single_user_not_found(): + r = requests.get(f"{BASE}/users/9999") + assert r.status_code == 404 diff --git a/tests/test_api_post.py b/tests/test_api_post.py index e69de29..48436ab 100644 --- a/tests/test_api_post.py +++ b/tests/test_api_post.py @@ -0,0 +1,21 @@ +import requests + +BASE = "https://jsonplaceholder.typicode.com" + +def test_post_create_post_status_201(): + payload = {"title": "qa test", "body": "automated test run", "userId": 1} + r = requests.post(f"{BASE}/posts", json=payload) + assert r.status_code == 201 + assert r.json()["title"] == "qa test" + +def test_post_create_post_missing_title(): + payload = {"body": "no title field", "userId": 1} + r = requests.post(f"{BASE}/posts", json=payload) + assert r.status_code == 201 + assert "id" in r.json() + +def test_post_create_post_empty_payload(): + payload = {} + r = requests.post(f"{BASE}/posts", json=payload) + assert r.status_code == 201 + assert "id" in r.json() |