You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ada-project-docs/wave_01.md
+17-28Lines changed: 17 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,17 +55,21 @@ We might also consider creating a route helper method that can:
55
55
56
56
## CRUD for Tasks
57
57
58
-
### Tips
58
+
Use the tests in `tests/test_wave_01.py` to guide your implementation.
59
59
60
-
- Pay attention to the exact shape of the expected JSON. Double-check nested data structures and the names of the keys for any misspellings.
61
-
- That said, remember that dictionaries do not have an implied order. This is still true in JSON with objects. When you make Postman requests, the order of the key/value pairings within the response JSON object does not need to match the order specified in this document. (The term "object" in JSON is analogous to "dictionary" in Python.)
62
-
- Notice that the details for a Task in the response is shared across all the endpoints that return Task details. Rather than repeating the same literal `dict` structure in each response, we should create a helper method that returns the `dict` structure for a Task, and use it in each relevant endpoint. This will ensure that all our responses are consistent.
63
-
- Use the tests in `tests/test_wave_01.py` to guide your implementation.
64
60
- You may feel that there are missing tests and missing edge cases considered in this wave. This is intentional.
65
61
- You have fulfilled wave 1 requirements if all of the wave 1 tests pass.
66
62
- You are free to add additional features, as long as the wave 1 tests still pass. However, we recommend that you consider the future waves, first.
67
63
- Some tests use a fixture named `one_task` that is defined in `tests/conftest.py`. This fixture saves a specific task to the test database.
68
64
65
+
### CRUD Tips
66
+
67
+
- Pay attention to the exact shape of the expected JSON. Double-check nested data structures and the names of the keys for any misspellings.
68
+
- That said, remember that dictionaries do not have an implied order. This is still true in JSON with objects. When you make Postman requests, the order of the key/value pairings within the response JSON object does not need to match the order specified in this document. (The term "object" in JSON is analogous to "dictionary" in Python.)
69
+
- Notice that the details for a Task in the response is shared across all the endpoints that return Task details. Rather than repeating the same literal `dict` structure in each response, we should create a helper method that returns the `dict` structure for a Task, and use it in each relevant endpoint. This will ensure that all our responses are consistent.
70
+
- We should remember that retrieving a model by its ID is a common operation. We should consider creating a route helper method that can retrieve a model by its ID, and use it in all applicable routes.
71
+
- This method could start out only working for Task models. But, knowing that we'll be working with Goal models later on, it might be worth generalizing this method to work with any model.
72
+
69
73
### CLI
70
74
71
75
In addition to testing your code with pytest and postman, you can play test your code with the CLI (Command Line Interface) by running `python3 cli/main.py`.
@@ -94,21 +98,17 @@ and get this response:
94
98
95
99
```json
96
100
{
97
-
"task": {
98
-
"id": 1,
99
-
"title": "A Brand New Task",
100
-
"description": "Test Description",
101
-
"is_complete": false
102
-
}
101
+
"id": 1,
102
+
"title": "A Brand New Task",
103
+
"description": "Test Description",
104
+
"is_complete": false
103
105
}
104
106
```
105
107
106
108
so that I know I successfully created a Task that is saved in the database.
107
109
108
110
Remember that the knowledge of how to initialize a new model instance from the request dictionary is often left to the model itself, as it allows the model to control which fields are required and how they are initialized. We could add a class method to the Task model that initializes a new instance from a dictionary, and use this method in the route. If all of our models have this method, we could create a route helper method that initializes a new model instance from a dictionary, and use it in this route and any other route that creates a new model instance.
109
111
110
-
Further, notice that the data nested under the `"task"` key is a dictionary representation of the task that was created. Creating a model helper method to return this dictionary, which we can then use to help build this route response, will improve the consistency of our endpoints.
111
-
112
112
#### Get Tasks: Getting Saved Tasks
113
113
114
114
As a client, I want to be able to make a `GET` request to `/tasks` when there is at least one saved task and get this response:
@@ -132,8 +132,6 @@ As a client, I want to be able to make a `GET` request to `/tasks` when there is
132
132
]
133
133
```
134
134
135
-
Notice that each data item in the list is a dictionary representation of a task. Creating a model helper method to return this dictionary, which we can then use to help build this route response, will improve the consistency of our endpoints.
136
-
137
135
#### Get Tasks: No Saved Tasks
138
136
139
137
As a client, I want to be able to make a `GET` request to `/tasks` when there are zero saved tasks and get this response:
@@ -152,18 +150,13 @@ As a client, I want to be able to make a `GET` request to `/tasks/1` when there
152
150
153
151
```json
154
152
{
155
-
"task": {
156
-
"id": 1,
157
-
"title": "Example Task Title 1",
158
-
"description": "Example Task Description 1",
159
-
"is_complete": false
160
-
}
153
+
"id": 1,
154
+
"title": "Example Task Title 1",
155
+
"description": "Example Task Description 1",
156
+
"is_complete": false
161
157
}
162
158
```
163
159
164
-
Notice that the data nested under the `"task"` key is a dictionary representation of the task that was retrieved. Creating a model helper method to return this dictionary, which we can then use to help build this route response, will improve the consistency of our endpoints.
165
-
166
-
Further, we should remember that retrieving a model by its ID is a common operation. We should consider creating a route helper method that can retrieve a model by its ID, and use it in this route. This method could start out only working for Task models. But knowing that we'll be working with Goal models later on, it might be worth generalizing this method to work with any model.
167
160
168
161
#### Update Task
169
162
@@ -184,8 +177,6 @@ The response should have a mimetype of "application/json" to keep our API respon
184
177
185
178
Note that the update endpoint does update the `completed_at` attribute. This will be updated with custom endpoints implemented in Wave 3.
186
179
187
-
We should remember that retrieving a model by its ID is a common operation. We should consider creating a route helper method that can retrieve a model by its ID, and use it in this route. This method could start out only working for Task models. But knowing that we'll be working with Goal models later on, it might be worth generalizing this method to work with any model.
188
-
189
180
#### Delete Task: Deleting a Task
190
181
191
182
As a client, I want to be able to make a `DELETE` request to `/tasks/1` when there is at least one saved task and get this response:
@@ -194,8 +185,6 @@ As a client, I want to be able to make a `DELETE` request to `/tasks/1` when the
194
185
195
186
The response should have a mimetype of "application/json" to keep our API response type consistent.
196
187
197
-
We should remember that retrieving a model by its ID is a common operation. We should consider creating a route helper method that can retrieve a model by its ID, and use it in this route. This method could start out only working for Task models. But knowing that we'll be working with Goal models later on, it might be worth generalizing this method to work with any model.
198
-
199
188
#### No Matching Task: Get, Update, and Delete
200
189
201
190
As a client, if I make any of the following requests:
Copy file name to clipboardExpand all lines: ada-project-docs/wave_02.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,16 @@ Our task list API allows users to create tasks and get a list of all tasks. Our
8
8
9
9
The following are required routes for wave 2. Feel free to implement the routes in any order within this wave.
10
10
11
-
### Tips
12
-
13
-
- Pay attention to the exact shape of the expected JSON. Double-check nested data structures and the names of the keys for any misspellings.
14
-
- Use the tests in `tests/test_wave_02.py` to guide your implementation.
11
+
Use the tests in `tests/test_wave_02.py` to guide your implementation.
15
12
- You may feel that there are missing tests and missing edge cases considered in this wave. This is intentional.
16
13
- You have fulfilled wave 2 requirements if all of the wave 2 tests pass.
17
14
- You are free to add additional features, as long as the wave 2 tests still pass. However, we recommend that you consider the future waves, first.
18
15
- Some tests use a fixture named `three_tasks` that is defined in `tests/conftest.py`. This fixture saves three different tasks with three different titles to the test database.
19
16
17
+
### Tips
18
+
19
+
- Pay attention to the exact shape of the expected JSON. Double-check nested data structures and the names of the keys for any misspellings.
20
+
20
21
### Sorting Tasks: By Title, Ascending
21
22
22
23
As a client, I want to be able to make a `GET` request to `/tasks?sort=asc` when there is more than one saved task, and get an array of tasks sorted by **title**. The titles should be in _ascending_ order, where a task with the title "A" is sorted before a task with the title "B."
Copy file name to clipboardExpand all lines: ada-project-docs/wave_03.md
+25-37Lines changed: 25 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,28 @@
4
4
5
5
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."
6
6
7
-
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`.
7
+
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 indicates whether`is_complete` is `true` or `false`.
8
8
9
-
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.
9
+
A task's `is_complete` is:
10
+
-`true` when there is a datetime for the task's `completed_at` value.
11
+
-`false` when there is a `null`/`None` value for the tasks's `completed_at` value.
10
12
11
13
## Requirements
12
14
13
15
The following are required routes for wave 3. Feel free to implement the routes in any order within this wave.
14
16
15
-
### Tips
16
-
17
-
- Use the tests in `tests/test_wave_3.py` to guide your implementation.
17
+
Use the tests in `tests/test_wave_3.py` to guide your implementation.
18
18
- You may feel that there are missing tests and missing edge cases considered in this wave. This is intentional.
19
19
- You have fulfilled wave 3 requirements if all of the wave 3 tests pass.
20
20
- 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.
21
21
- A test uses a fixture named `completed_task` that is defined in `tests/conftest.py`. This fixture saves a task with a datetime value in `completed_at` to the test database.
22
+
23
+
### Tips
24
+
22
25
- JSON's value of `true` is similar to Python's value of `True`, and `false` is similar to Python's `False`.
23
26
- SQL's value of `null` is similar to Python's value of `None`.
24
27
- Python has a [datetime library](https://docs.python.org/3/library/datetime.html#module-datetime) which we recommend using to represent dates in model attributes.
28
+
- Notice that these routes require that we look up a model by its ID, and then update that model. We should be able to reuse the same route helper methods that we have been using in other Task routes to help build these routes.
25
29
26
30
### Mark Complete on an Incomplete Task
27
31
@@ -44,12 +48,10 @@ After I have made the `PATCH` request, I can submit a `GET` request to `/tasks/1
44
48
45
49
```json
46
50
{
47
-
"task": {
48
-
"id": 1,
49
-
"title": "Go on my daily walk 🏞",
50
-
"description": "Notice something new every day",
51
-
"is_complete": true
52
-
}
51
+
"id": 1,
52
+
"title": "Go on my daily walk 🏞",
53
+
"description": "Notice something new every day",
54
+
"is_complete": true
53
55
}
54
56
```
55
57
@@ -74,12 +76,10 @@ After I have made the `PATCH` request, I can submit a `GET` request to `/tasks/1
74
76
75
77
```json
76
78
{
77
-
"task": {
78
-
"id": 1,
79
-
"title": "Go on my daily walk 🏞",
80
-
"description": "Notice something new every day",
81
-
"is_complete": false
82
-
}
79
+
"id": 1,
80
+
"title": "Go on my daily walk 🏞",
81
+
"description": "Notice something new every day",
82
+
"is_complete": false
83
83
}
84
84
```
85
85
@@ -104,19 +104,13 @@ After I have made the `PATCH` request, I can submit a `GET` request to `/tasks/1
104
104
105
105
```json
106
106
{
107
-
"task": {
108
-
"id": 1,
109
-
"title": "Go on my daily walk 🏞",
110
-
"description": "Notice something new every day",
111
-
"is_complete": true
112
-
}
107
+
"id": 1,
108
+
"title": "Go on my daily walk 🏞",
109
+
"description": "Notice something new every day",
110
+
"is_complete": true
113
111
}
114
112
```
115
113
116
-
Notice the same dictionary structure for the Task data as in our wave 1 routes. We should be able to use any response model helper that we are using in other Task routes to help build this response.
117
-
118
-
Also notice that fundamentally, this route requires that we look up a model by its ID, and then update that model. We should be able to reuse the same route helper methods that we have been using in other Task routes to help build this route.
119
-
120
114
### Mark Incomplete on an Incomplete Task
121
115
122
116
Given a task that has:
@@ -138,19 +132,13 @@ After I have made the `PATCH` request, I can submit a `GET` request to `/tasks/1
138
132
139
133
```json
140
134
{
141
-
"task": {
142
-
"id": 1,
143
-
"title": "Go on my daily walk 🏞",
144
-
"description": "Notice something new every day",
145
-
"is_complete": false
146
-
}
135
+
"id": 1,
136
+
"title": "Go on my daily walk 🏞",
137
+
"description": "Notice something new every day",
138
+
"is_complete": false
147
139
}
148
140
```
149
141
150
-
Notice the same dictionary structure for the Task data as in our wave 1 routes. We should be able to use any response model helper that we are using in other Task routes to help build this response.
151
-
152
-
Also notice that fundamentally, this route requires that we look up a model by its ID, and then update that model. We should be able to reuse the same route helper methods that we have been using in other Task routes to help build this route.
153
-
154
142
## Mark Complete and Mark Incomplete for Missing Tasks
Our Slackbot token is an API key that needs to be protected.
177
-
178
-
Include your Slackbot token in your code in an intentional way, following best practices about API keys in code bases.
176
+
Our Slackbot token is an API key that needs to be protected. Include your Slackbot token in your code in an intentional way, following best practices about API keys in code bases.
179
177
180
178
### Requirement: Use Python package `requests` to make HTTP calls
181
179
182
-
Remember to import this package
183
-
184
-
Consider using the keyword argument `data`, `json`, and/or `headers`
180
+
Remember to import the `requests` package. Consider using the keyword argument `data`, `json`, and/or `headers`.
185
181
186
182
#### Tips
187
-
- Remember to put your Slackbot token in your code in an intentional way, following best practices about API keys in code bases.
188
183
- In order to get the value of an environment variable, use `os.environ.get()`, just as we used it for the database configuration.
189
184
- Use your work from the Slack API documentation, the Slack tester, and Postman to guide your implementation.
0 commit comments