aboutsummaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorMichael McVady <femtonaut@gmail.com>2023-01-06 06:31:15 -0600
committerMichael McVady <femtonaut@gmail.com>2023-01-06 06:31:15 -0600
commit850df3b8721963b6fefc226b533c347cde79ff25 (patch)
tree4cba77c8f758d251ba61883820801abc879091c7 /tests.py
parentd88f5cced222ac76511702a80e26dc7de8af93f3 (diff)
Hack in POST handling; needs refactoring
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"})