Created
February 2, 2023 10:32
-
-
Save se1983/6d11166fa85036dd87c05c183450cf64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import requests | |
""" Develop an asynchronous REST API with any Python Framework you like. """ | |
BONUS_POINTS = False | |
def test_api(): | |
resp = requests.post("http://localhost:8000/elements/", data = {"name": "interview-success"}) | |
assert resp.status_code == 200 | |
assert list(resp.json().keys()) == ["href", "status"] | |
href = resp.json()["href"] | |
if BONUS_POINTS: | |
assert requests.get(url=href).status_code == 404 | |
time.sleep(5) | |
resp = requests.get(url=href) | |
assert resp.status_code == 200 | |
assert list(resp.json().keys()) == ["name", "id", "created"] | |
assert resp.json()["name"] == "INTERVIEW SUCCESS" | |
test_api() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment