22from app .db import db
33import pytest
44
5+ # @pytest.mark.skip(reason="No way to test this feature yet")
6+ def test_task_to_dict ():
7+ #Arrange
8+ new_task = Task (title = "Make My Bed" ,
9+ description = "Start the day off right!" ,
10+ completed_at = None )
11+
12+ #Act
13+ task_dict = new_task .to_dict ()
14+ #Assert
15+ assert task_dict == {
16+ "id" : None ,
17+ "title" : "Make My Bed" ,
18+ "description" : "Start the day off right!" ,
19+ "is_complete" : False
20+ }
521
6- @pytest .mark .skip (reason = "No way to test this feature yet" )
22+ # @pytest.mark.skip(reason="No way to test this feature yet")
23+ def test_task_from_dict ():
24+ #Arrange
25+ task_dict = {
26+ "title" : "Make My Bed" ,
27+ "description" : "Start the day off right!" ,
28+ "is_complete" : False
29+ }
30+
31+ expected_task = Task (title = "Make My Bed" ,
32+ description = "Start the day off right!" ,
33+ completed_at = None )
34+ #Act
35+ task_obj = Task .from_dict (task_dict )
36+
37+ #Assert
38+ assert task_obj .id is None
39+ assert task_obj .title == expected_task .title
40+ assert task_obj .description == expected_task .description
41+ assert task_obj .completed_at == expected_task .completed_at
42+
43+ # @pytest.mark.skip(reason="No way to test this feature yet")
744def test_get_tasks_no_saved_tasks (client ):
845 # Act
946 response = client .get ("/tasks" )
@@ -14,7 +51,7 @@ def test_get_tasks_no_saved_tasks(client):
1451 assert response_body == []
1552
1653
17- @pytest .mark .skip (reason = "No way to test this feature yet" )
54+ # @pytest.mark.skip(reason="No way to test this feature yet")
1855def test_get_tasks_one_saved_tasks (client , one_task ):
1956 # Act
2057 response = client .get ("/tasks" )
@@ -33,7 +70,7 @@ def test_get_tasks_one_saved_tasks(client, one_task):
3370 ]
3471
3572
36- @pytest .mark .skip (reason = "No way to test this feature yet" )
73+ # @pytest.mark.skip(reason="No way to test this feature yet")
3774def test_get_task (client , one_task ):
3875 # Act
3976 response = client .get ("/tasks/1" )
@@ -67,7 +104,7 @@ def test_get_task_not_found(client):
67104 # *****************************************************************
68105
69106
70- @pytest .mark .skip (reason = "No way to test this feature yet" )
107+ # @pytest.mark.skip(reason="No way to test this feature yet")
71108def test_create_task (client ):
72109 # Act
73110 response = client .post ("/tasks" , json = {
@@ -96,8 +133,7 @@ def test_create_task(client):
96133 assert new_task .description == "Test Description"
97134 assert new_task .completed_at == None
98135
99-
100- @pytest .mark .skip (reason = "No way to test this feature yet" )
136+ # @pytest.mark.skip(reason="No way to test this feature yet")
101137def test_update_task (client , one_task ):
102138 # Act
103139 response = client .put ("/tasks/1" , json = {
@@ -135,7 +171,7 @@ def test_update_task_not_found(client):
135171 # *****************************************************************
136172
137173
138- @pytest .mark .skip (reason = "No way to test this feature yet" )
174+ # @pytest.mark.skip(reason="No way to test this feature yet")
139175def test_delete_task (client , one_task ):
140176 # Act
141177 response = client .delete ("/tasks/1" )
@@ -163,7 +199,7 @@ def test_delete_task_not_found(client):
163199 assert db .session .scalars (db .select (Task )).all () == []
164200
165201
166- @pytest .mark .skip (reason = "No way to test this feature yet" )
202+ # @pytest.mark.skip(reason="No way to test this feature yet")
167203def test_create_task_must_contain_title (client ):
168204 # Act
169205 response = client .post ("/tasks" , json = {
@@ -180,7 +216,7 @@ def test_create_task_must_contain_title(client):
180216 assert db .session .scalars (db .select (Task )).all () == []
181217
182218
183- @pytest .mark .skip (reason = "No way to test this feature yet" )
219+ # @pytest.mark.skip(reason="No way to test this feature yet")
184220def test_create_task_must_contain_description (client ):
185221 # Act
186222 response = client .post ("/tasks" , json = {
0 commit comments