aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 533d2c2..33c9f6d 100755
--- a/tests.py
+++ b/tests.py
@@ -2,6 +2,7 @@
import json
import sys
+import uuid
import requests
@@ -94,6 +95,30 @@ def test_json_get_posts():
assert "Debugging CGI / CGit" in text
+def test_json_post_posts():
+ url = f"{BASE_URL}/posts"
+ uuid_ = str(uuid.uuid4())
+ data = {"id": uuid_, "title": "title", "body": "body"}
+ r = requests.post(url, headers={"Accept": "application/json"}, json=data)
+ # FIXME need to refactor to fix status code here.
+ # assert r.status_code == 201
+ assert r.status_code == 200
+ j = r.json()
+
+ assert len(j) == 1
+ assert "title" == j[0]["title"]
+ assert "body" == j[0]["body"]
+
+ url = f"{BASE_URL}/posts/{uuid_}"
+ r = requests.get(url, headers={"Accept": "application/json"})
+ assert r.status_code == 200
+ j = r.json()
+
+ assert len(j) == 1
+ assert "title" == j[0]["title"]
+ assert "body" == j[0]["body"]
+
+
def test_json_get_post_not_found():
url = f"{BASE_URL}/posts/{BAD_UUID}"
r = requests.get(url, headers={"Accept": "application/json"})