def test_task_when_list_task_a_task_should_have_description(): TASKS.append({"description": "this is a task"}) client = TestClient(app) response = client.get("/tasks") assert "description" in response.json().pop() TASKS.clear()
def test_task_when_list_task_a_task_should_have_status(): TASKS.append({"status": "done"}) client = TestClient(app) response = client.get("/tasks") assert "status" in response.json().pop()
def test_when_list_task_a_task_should_have_id(): TASKS.append({"id": 1}) client = TestClient(app) response = client.get("/tasks") assert "id" in response.json().pop() TASKS.clear()
def test_when_list_task_a_task_should_have_name(): TASKS.append({"name": "name one"}) client = TestClient(app) response = client.get("/tasks") assert "name" in response.json().pop() TASKS.clear()
def test_when_create_task_its_id_should_be_unique(client, task): task_1 = {'title': 'title_1', 'description': 'description_1'} response = client.post('/tasks', json=task) response_1 = client.post('/tasks', json=task_1) assert response.json()['id'] != response_1.json()['id'] TASKS.clear()
def test_when_create_task_status_should_be_in_progress(client, task): response = client.post('/tasks', json=task) assert response.json()['status'] == 'in progress' TASKS.clear()
def test_when_create_task_it_should_be_returned(client, task): response = client.post('/tasks', json=task) assert response.json()['title'] == task['title'] assert response.json()['description'] == task['description'] TASKS.clear()
def test_when_list_tasks_returned_task_should_have_status(): TASKS.append({'status': 'done'}) client = TestClient(app) response = client.get('/tasks') assert 'status' in response.json().pop() TASKS.clear()
def test_when_list_tasks_returned_task_should_have_description(): TASKS.append({'description': 'description 1'}) client = TestClient(app) response = client.get('/tasks') assert 'description' in response.json().pop() TASKS.clear()
def test_when_list_tasks_returned_task_should_have_title(): TASKS.append({'title': 'title 1'}) client = TestClient(app) response = client.get('/tasks') assert 'title' in response.json().pop() TASKS.clear()
def test_when_create_task_should_be_stored(client, task): response = client.post('/tasks', json=task) assert response.status_code == 201 assert len(TASKS) == 1 TASKS.clear()