diff options
author | Michael McVady <femtonaut@gmail.com> | 2023-01-06 06:31:15 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2023-01-06 06:31:15 -0600 |
commit | 850df3b8721963b6fefc226b533c347cde79ff25 (patch) | |
tree | 4cba77c8f758d251ba61883820801abc879091c7 /tests.py | |
parent | d88f5cced222ac76511702a80e26dc7de8af93f3 (diff) |
Hack in POST handling; needs refactoring
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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"}) |