2
2
import pytest
3
3
4
4
5
- @pytest .mark .skip (reason = "No way to test this feature yet" )
5
+ # @pytest.mark.skip(reason="No way to test this feature yet")
6
6
def test_get_tasks_no_saved_tasks (client ):
7
7
# Act
8
8
response = client .get ("/tasks" )
@@ -13,7 +13,7 @@ def test_get_tasks_no_saved_tasks(client):
13
13
assert response_body == []
14
14
15
15
16
- @pytest .mark .skip (reason = "No way to test this feature yet" )
16
+ # @pytest.mark.skip(reason="No way to test this feature yet")
17
17
def test_get_tasks_one_saved_tasks (client , one_task ):
18
18
# Act
19
19
response = client .get ("/tasks" )
@@ -32,7 +32,7 @@ def test_get_tasks_one_saved_tasks(client, one_task):
32
32
]
33
33
34
34
35
- @pytest .mark .skip (reason = "No way to test this feature yet" )
35
+ # @pytest.mark.skip(reason="No way to test this feature yet")
36
36
def test_get_task (client , one_task ):
37
37
# Act
38
38
response = client .get ("/tasks/1" )
@@ -51,22 +51,19 @@ def test_get_task(client, one_task):
51
51
}
52
52
53
53
54
- @pytest .mark .skip (reason = "No way to test this feature yet" )
54
+ # @pytest.mark.skip(reason="No way to test this feature yet")
55
55
def test_get_task_not_found (client ):
56
56
# Act
57
57
response = client .get ("/tasks/1" )
58
58
response_body = response .get_json ()
59
59
60
60
# Assert
61
61
assert response .status_code == 404
62
+ assert "message" in response_body
63
+ assert response_body ["message" ] == "Task 1 not found"
62
64
63
- raise Exception ("Complete test with assertion about response body" )
64
- # *****************************************************************
65
- # **Complete test with assertion about response body***************
66
- # *****************************************************************
67
65
68
-
69
- @pytest .mark .skip (reason = "No way to test this feature yet" )
66
+ # @pytest.mark.skip(reason="No way to test this feature yet")
70
67
def test_create_task (client ):
71
68
# Act
72
69
response = client .post ("/tasks" , json = {
@@ -93,7 +90,7 @@ def test_create_task(client):
93
90
assert new_task .completed_at == None
94
91
95
92
96
- @pytest .mark .skip (reason = "No way to test this feature yet" )
93
+ # @pytest.mark.skip(reason="No way to test this feature yet")
97
94
def test_update_task (client , one_task ):
98
95
# Act
99
96
response = client .put ("/tasks/1" , json = {
@@ -119,7 +116,7 @@ def test_update_task(client, one_task):
119
116
assert task .completed_at == None
120
117
121
118
122
- @pytest .mark .skip (reason = "No way to test this feature yet" )
119
+ # @pytest.mark.skip(reason="No way to test this feature yet")
123
120
def test_update_task_not_found (client ):
124
121
# Act
125
122
response = client .put ("/tasks/1" , json = {
@@ -130,14 +127,11 @@ def test_update_task_not_found(client):
130
127
131
128
# Assert
132
129
assert response .status_code == 404
133
-
134
- raise Exception ("Complete test with assertion about response body" )
135
- # *****************************************************************
136
- # **Complete test with assertion about response body***************
137
- # *****************************************************************
130
+ assert "message" in response_body
131
+ assert response_body ["message" ] == "Task 1 not found"
138
132
139
133
140
- @pytest .mark .skip (reason = "No way to test this feature yet" )
134
+ # @pytest.mark.skip(reason="No way to test this feature yet")
141
135
def test_delete_task (client , one_task ):
142
136
# Act
143
137
response = client .delete ("/tasks/1" )
@@ -152,7 +146,7 @@ def test_delete_task(client, one_task):
152
146
assert Task .query .get (1 ) == None
153
147
154
148
155
- @pytest .mark .skip (reason = "No way to test this feature yet" )
149
+ # @pytest.mark.skip(reason="No way to test this feature yet")
156
150
def test_delete_task_not_found (client ):
157
151
# Act
158
152
response = client .delete ("/tasks/1" )
@@ -161,15 +155,12 @@ def test_delete_task_not_found(client):
161
155
# Assert
162
156
assert response .status_code == 404
163
157
164
- raise Exception ("Complete test with assertion about response body" )
165
- # *****************************************************************
166
- # **Complete test with assertion about response body***************
167
- # *****************************************************************
168
-
158
+ assert "message" in response_body
159
+ assert response_body ["message" ] == "Task 1 not found"
169
160
assert Task .query .all () == []
170
161
171
162
172
- @pytest .mark .skip (reason = "No way to test this feature yet" )
163
+ # @pytest.mark.skip(reason="No way to test this feature yet")
173
164
def test_create_task_must_contain_title (client ):
174
165
# Act
175
166
response = client .post ("/tasks" , json = {
@@ -186,7 +177,7 @@ def test_create_task_must_contain_title(client):
186
177
assert Task .query .all () == []
187
178
188
179
189
- @pytest .mark .skip (reason = "No way to test this feature yet" )
180
+ # @pytest.mark.skip(reason="No way to test this feature yet")
190
181
def test_create_task_must_contain_description (client ):
191
182
# Act
192
183
response = client .post ("/tasks" , json = {
@@ -200,4 +191,4 @@ def test_create_task_must_contain_description(client):
200
191
assert response_body == {
201
192
"details" : "Invalid data"
202
193
}
203
- assert Task .query .all () == []
194
+ assert Task .query .all () == []
0 commit comments