Our task list API allows users to meaningfully use the task resource. Users want to be able to mark a task as "complete" or "incomplete."
We want to design our API so that it stores a task's completed_at
date as a datetime value in our database. In this scenario, our API does not give users the completed_at
date... it only gives the information if is_complete
is true
or false
.
A task's is_complete
is true
when there is a datetime for the task's completed_at
value. A task's is_complete
is false
when there is a null
/None
value for the tasks's completed_at
value.
The following are required routes for wave 3. Feel free to implement the routes in any order within this wave.
- Use the tests in
tests/test_wave_3.py
to guide your implementation. - You may feel that there are missing tests and missing edge cases considered in this wave. This is intentional.
- You have fulfilled wave 3 requirements if all of the wave 3 tests pass.
- You are free to add additional features, as long as the wave 3 tests still pass. However, we recommend that you consider the future waves, first.
- A test uses a fixture named
completed_task
that is defined intests/conftest.py
. This fixture saves a task with a datetime value incompleted_at
to the test database. - JSON's value of
true
is similar to Python's value ofTrue
, andfalse
is similar to Python'sFalse
. - SQL's value of
null
is similar to Python's value ofNone
. - Python has a datetime library which we recommend using to represent dates in model attributes.
Given a task that has:
- An id
1
- A
completed_at
attribute with anull
value
when I send a PATCH
request to /tasks/1/mark_complete
,
then the task is updated, so that its completed_at
value is the current date, and I get this response:
200 OK
{
"task": {
"id": 1,
"title": "Go on my daily walk 🏞",
"description": "Notice something new every day",
"is_complete": true
}
}
Given a task that has:
- An id
1
- A
completed_at
attribute with a datetime value
when I send a PATCH
request to /tasks/1/mark_incomplete
,
then the task is updated, so that its completed_at
value is null
/None
, and I get this response:
200 OK
{
"task": {
"id": 1,
"title": "Go on my daily walk 🏞",
"description": "Notice something new every day",
"is_complete": false
}
}
Given a task that has:
- An id
1
- A
completed_at
attribute with a datetime value
when I send a PATCH
request to /tasks/1/mark_complete
,
then I want this to behave exactly like /tasks/1/mark_complete
for an incomplete task. The task is updated, so that its completed_at
value is the current date, and I get this response:
200 OK
{
"task": {
"id": 1,
"title": "Go on my daily walk 🏞",
"description": "Notice something new every day",
"is_complete": true
}
}
Given a task that has:
- An id
1
- A
completed_at
attribute with anull
value
when I send a PATCH
request to /tasks/1/mark_incomplete
,
then I want this to behave exactly like /tasks/1/mark_incomplete
for a complete task. Its completed_at
value remains as null
/None
, and I get this response:
200 OK
{
"task": {
"id": 1,
"title": "Go on my daily walk 🏞",
"description": "Notice something new every day",
"is_complete": false
}
}
Given that there are no tasks with the ID 1
,
When I send a PATCH
request to /tasks/1/mark_complete
or a PATCH
request to /tasks/1/mark_incomplete
,
Then I get a 404 Not Found
, with no response body.