From 3a4e30b6e01f075d880957fde056d52ec3a82c15 Mon Sep 17 00:00:00 2001 From: pack Date: Mon, 8 Jun 2026 13:47:19 +0000 Subject: add 10 API tests against jsonplaceholder.typicode.com, get post, edge cases --- tests/test_api_post.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/test_api_post.py') 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() -- cgit v1.2.3