diff options
author | Michael McVady <femtonaut@gmail.com> | 2023-10-29 16:45:51 -0500 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2023-10-29 17:55:59 -0500 |
commit | 2e3ceb247fa63db0bbf9ba71f06be50eeda74445 (patch) | |
tree | f4df7ea41ba427b76ad173c032347877fd9beb90 /tests.py | |
parent | 350ed67cc50c562459aaa34f7b6eefc389bec370 (diff) |
Refactor: `post` -> `entry`
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 56 |
1 files changed, 28 insertions, 28 deletions
@@ -6,9 +6,9 @@ import uuid import requests BASE_URL = "http://localhost:8888" -POSTS_URL = f"{BASE_URL}/posts" +ENTRIES_URL = f"{BASE_URL}/entries" -FONT_RENDERING_POST_UUID = "6d011855-6b0d-4202-a243-4d9db9807f14" +FONT_RENDERING_ENTRY_UUID = "6d011855-6b0d-4202-a243-4d9db9807f14" BAD_UUID = "00000000-0000-1111-0000-000000000000" INVALID_UUID = "0" @@ -25,8 +25,8 @@ def test_redirect(): assert r.headers["Location"] == "/" -def test_get_post(): - r = requests.get(f"{POSTS_URL}/{FONT_RENDERING_POST_UUID}") +def test_get_entry(): + r = requests.get(f"{ENTRIES_URL}/{FONT_RENDERING_ENTRY_UUID}") assert r.status_code == 200 assert "A Solid Breakdown of the Linux Font Rendering Stack" in r.text assert "hinting and anti-aliasing" in r.text @@ -43,8 +43,8 @@ def test_get_base_url(): assert "Debugging CGI / CGit" in r.text -def test_get_posts(): - r = requests.get(POSTS_URL) +def test_get_entries(): + r = requests.get(ENTRIES_URL) assert r.status_code == 200 assert "A Solid Breakdown of the Linux Font Rendering Stack" in r.text assert "hinting and anti-aliasing" in r.text @@ -52,94 +52,94 @@ def test_get_posts(): assert "Debugging CGI / CGit" in r.text -def test_get_post_not_found(): - r = requests.get(f"{POSTS_URL}/{BAD_UUID}") +def test_get_entry_not_found(): + r = requests.get(f"{ENTRIES_URL}/{BAD_UUID}") assert r.status_code == 404 assert "Resource not found" in r.text - r = requests.get(f"{POSTS_URL}/{INVALID_UUID}") + r = requests.get(f"{ENTRIES_URL}/{INVALID_UUID}") assert r.status_code == 404 assert "Resource not found" in r.text -def test_post_posts(): +def test_post_entry(): uuid_ = str(uuid.uuid4()) title = "Moby Dick" body = "Call me Ismael" data = {"id": uuid_, "title": title, "body": body} - r = requests.post(POSTS_URL, headers=JSON_ACCEPT_HEADER, json=data) + r = requests.post(ENTRIES_URL, headers=JSON_ACCEPT_HEADER, json=data) assert r.status_code == 201 assert "Resource created successfully." in r.text - posts_uuid_url = f"{POSTS_URL}/{uuid_}" - r = requests.get(posts_uuid_url) + entry_url = f"{ENTRIES_URL}/{uuid_}" + r = requests.get(entry_url) assert r.status_code == 200 assert title in r.text assert body in r.text - r = requests.delete(posts_uuid_url) + r = requests.delete(entry_url) assert r.status_code == 200 -def test_put_posts(): +def test_put_entry(): uuid_ = str(uuid.uuid4()) r = requests.post( - POSTS_URL, + ENTRIES_URL, headers=JSON_ACCEPT_HEADER, json={"id": uuid_, "title": "title", "body": "body"}, ) assert r.status_code == 201 assert "Resource created successfully." in r.text - post_uuid_url = f"{POSTS_URL}/{uuid_}" - r = requests.get(post_uuid_url) + entry_url = f"{ENTRIES_URL}/{uuid_}" + r = requests.get(entry_url) assert r.status_code == 200 assert "title" in r.text assert "body" in r.text r = requests.put( - post_uuid_url, + entry_url, headers=JSON_ACCEPT_HEADER, json={"title": "title2", "body": "body2"}, ) assert r.status_code == 200 assert "OK" in r.text - r = requests.get(post_uuid_url) + r = requests.get(entry_url) assert r.status_code == 200 # assert len(j) == 1 assert "title2" in r.text assert "body2" in r.text - r = requests.delete(post_uuid_url) + r = requests.delete(entry_url) assert r.status_code == 200 assert "OK" in r.text -def test_delete_posts(): +def test_delete_entry(): uuid_ = str(uuid.uuid4()) - post_uuid_url = f"{POSTS_URL}/{uuid_}" + entry_url = f"{ENTRIES_URL}/{uuid_}" - # Delete POST if exists - r = requests.delete(post_uuid_url) + # Delete entry if exists + r = requests.delete(entry_url) assert r.status_code in (200, 404) # FIXME: Still JSON title = "Hackers" body = "Hack the planet!" r = requests.post( - POSTS_URL, + ENTRIES_URL, headers=JSON_ACCEPT_HEADER, json={"id": uuid_, "title": title, "body": body}, ) assert r.status_code == 201, f"Unexpected status code: {r.status_code} == 201" assert "Resource created successfully" in r.text - r = requests.delete(post_uuid_url) + r = requests.delete(entry_url) assert r.status_code == 200 assert "OK" in r.text - r = requests.get(post_uuid_url) + r = requests.get(entry_url) assert r.status_code == 404 assert "Resource not found" in r.text |