You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB
Python

def test_welcome_route(client):
message = "welcome to {{cookiecutter.project_slug}}"
response = client.get("/")
content = response.json()
assert message == content.get("message")
6 years ago
def test_empty_get_todos(client):
response = client.get("/todos")
assert response.status_code == 200
assert response.json() == []
6 years ago
def test_insert_todo(client):
payload = {"todo": "walk the dog"}
response = client.post("/todos", data=payload)
6 years ago
content = response.json()
assert response.status_code == 201
assert type(content['id']) == int
assert content['todo'] == payload['todo']
def test_update_todo(client):
payload = {"todo": "sample app"}
response = client.post("/todos", json=payload)
todo = response.json()
print(todo)
update_response = client.patch("{}".format(todo.get("href")), json={"complete": True, "todo": "sample app"})
updated_todo = update_response.json()
print(updated_todo)
assert updated_todo["complete"] == True
def test_todo_not_found(client):
response = client.get("/todo/1111111")
content = response.json()
assert response.status_code == 404
assert content["status"] == 404
assert content["message"]