aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_api_post.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-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()