1
+ from app .models .task import Task
2
+
3
+
1
4
def test_get_tasks_no_saved_tasks (client ):
2
5
# Act
3
6
response = client .get ("/tasks" )
@@ -74,6 +77,11 @@ def test_create_task_with_none_completed_at(client):
74
77
"is_complete" : False
75
78
}
76
79
}
80
+ new_task = Task .query .get (1 )
81
+ assert new_task
82
+ assert new_task .title == "A Brand New Task"
83
+ assert new_task .description == "Test Description"
84
+ assert new_task .completed_at == None
77
85
78
86
79
87
def test_update_task (client , one_task ):
@@ -96,6 +104,10 @@ def test_update_task(client, one_task):
96
104
"is_complete" : False
97
105
}
98
106
}
107
+ task = Task .query .get (1 )
108
+ assert task .title == "Updated Task Title"
109
+ assert task .description == "Updated Test Description"
110
+ assert task .completed_at == None
99
111
100
112
101
113
def test_update_task_not_found (client ):
@@ -123,11 +135,7 @@ def test_delete_task(client, one_task):
123
135
assert response_body == {
124
136
"details" : 'Task 1 "Go on my daily walk 🏞" successfully deleted'
125
137
}
126
-
127
- # Make another request to
128
- # check that the task was deleted
129
- response = client .get ("/tasks/1" )
130
- assert response .status_code == 404
138
+ assert Task .query .get (1 ) == None
131
139
132
140
133
141
def test_delete_task_not_found (client ):
@@ -138,6 +146,7 @@ def test_delete_task_not_found(client):
138
146
# Assert
139
147
assert response .status_code == 404
140
148
assert response_body == None
149
+ assert Task .query .all () == []
141
150
142
151
143
152
def test_create_task_must_contain_title (client ):
@@ -154,6 +163,7 @@ def test_create_task_must_contain_title(client):
154
163
assert response_body == {
155
164
"details" : "Invalid data"
156
165
}
166
+ assert Task .query .all () == []
157
167
158
168
159
169
def test_create_task_must_contain_description (client ):
@@ -170,6 +180,7 @@ def test_create_task_must_contain_description(client):
170
180
assert response_body == {
171
181
"details" : "Invalid data"
172
182
}
183
+ assert Task .query .all () == []
173
184
174
185
175
186
def test_create_task_must_contain_completed_at (client ):
@@ -186,3 +197,4 @@ def test_create_task_must_contain_completed_at(client):
186
197
assert response_body == {
187
198
"details" : "Invalid data"
188
199
}
200
+ assert Task .query .all () == []
0 commit comments