Ejemplo n.º 1
0
def test_deleting_a_task_really_removes_it_from_tasks_list():
    TASKS.append(copy(DEFAULT_TASK.dict()))
    client = TestClient(app)
    client.delete(f"/tasks/{DEFAULT_TASK.id}")
    resp = client.get(f"/tasks/{DEFAULT_TASK.id}")
    assert resp.status_code == status.HTTP_404_NOT_FOUND
    TASKS.clear()
Ejemplo n.º 2
0
def test_listing_tasks_sorted_by_description():
    TASKS.append(Task(id=uuid4(), title="xpto", description="banana").dict())
    TASKS.append(Task(id=uuid4(), title="xpto", description="melon").dict())
    TASKS.append(Task(id=uuid4(), title="xpto", description="apple").dict())
    client = TestClient(app)
    resp = client.get("/tasks?sort=true&sort_by=description")
    description_list = list(map(lambda task: task["description"], resp.json()))
    assert description_list == sorted(description_list)
    TASKS.clear()
Ejemplo n.º 3
0
def test_listing_tasks_with_sort_query_param_sorted_by_title():
    TASKS.append(Task(id=uuid4(), title="banana", description="xpto").dict())
    TASKS.append(Task(id=uuid4(), title="melon", description="xpto").dict())
    TASKS.append(Task(id=uuid4(), title="apple", description="xpto").dict())
    client = TestClient(app)
    resp = client.get("/tasks?sort=true")
    titles_list = list(map(lambda task: task["title"], resp.json()))
    assert titles_list == sorted(titles_list)
    TASKS.clear()
Ejemplo n.º 4
0
def test_listing_tasks_return_one_task_with_status():
    TASKS.append(copy(DEFAULT_TASK.dict()))
    client = TestClient(app)
    resp = client.get("/tasks")
    assert "status" in resp.json().pop()
    TASKS.clear()
Ejemplo n.º 5
0
def test_deleting_a_task_correctly_return_204():
    TASKS.append(copy(DEFAULT_TASK.dict()))
    client = TestClient(app)
    resp = client.delete(f"/tasks/{DEFAULT_TASK.id}")
    assert resp.status_code == status.HTTP_204_NO_CONTENT
    TASKS.clear()
Ejemplo n.º 6
0
def test_retrieving_task_ok_return_200():
    TASKS.append(copy(DEFAULT_TASK.dict()))
    client = TestClient(app)
    resp = client.get(f"/tasks/{DEFAULT_TASK.id}")
    assert resp.status_code == status.HTTP_200_OK
    TASKS.clear()