aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_api_post.py
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-06-08 13:47:19 +0000
committerpack <pack@packgekko.xyz>2026-06-08 13:47:19 +0000
commit3a4e30b6e01f075d880957fde056d52ec3a82c15 (patch)
tree501daa604a7726974257445ff4a5b17e1057ebf7 /tests/test_api_post.py
parent440d760882a27a3bc110dacaad92b6cfb29b5d7a (diff)
downloadqa_automation_bootcamp-3a4e30b6e01f075d880957fde056d52ec3a82c15.tar.gz
add 10 API tests against jsonplaceholder.typicode.com, get post, edge cases
Diffstat (limited to 'tests/test_api_post.py')
-rw-r--r--tests/test_api_post.py21
1 files changed, 21 insertions, 0 deletions
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()