1+ import pytest
2+
3+ from app .models .goal import Goal
4+ from app .models .task import Task
5+ from app .routes .route_utilities import create_model , validate_model
6+
7+ # @pytest.mark.skip(reason="No way to test this feature yet")
8+ def test_route_utilities_validate_model_with_task (client , three_tasks ):
9+ #Act
10+ task_1 = validate_model (Task , 1 )
11+ task_2 = validate_model (Task , 2 )
12+ task_3 = validate_model (Task , 3 )
13+
14+ #Assert
15+ assert task_1 .id == 1
16+ assert task_1 .title == "Water the garden 🌷"
17+ assert task_1 .description == ""
18+ assert task_1 .completed_at is None
19+
20+ assert task_2 .id == 2
21+ assert task_2 .title == "Answer forgotten email 📧"
22+
23+ assert task_3 .id == 3
24+ assert task_3 .title == "Pay my outstanding tickets 😭"
25+
26+ # @pytest.mark.skip(reason="No way to test this feature yet")
27+ def test_route_utilities_validate_model_with_goal (client , one_goal ):
28+ #Act
29+ goal_1 = validate_model (Goal , 1 )
30+
31+ #Assert
32+ assert goal_1 .id == 1
33+ assert goal_1 .title == "Build a habit of going outside daily"
34+
35+ # @pytest.mark.skip(reason="No way to test this feature yet")
36+ def test_route_utilities_create_model_with_task (client ):
37+ #Arrange
38+ request_body = {
39+ "title" : "Make the bed" ,
40+ "description" : "" ,
41+ "completed_at" : None
42+ }
43+
44+ #Act
45+ response = create_model (Task , request_body )
46+
47+ #Assert
48+ assert response [0 ]["id" ] == 1 #create_model returns a tuple
49+ assert response [0 ]["title" ] == "Make the bed"
50+ assert response [0 ]["description" ] == ""
51+ assert response [0 ]["is_complete" ] == False
52+ assert response [1 ] == 201
53+
54+ # @pytest.mark.skip(reason="No way to test this feature yet")
55+ def test_route_utilities_create_model_with_goal (client ):
56+ #Arrange
57+ request_body = {
58+ "title" : "Seize the Day!"
59+ }
60+
61+ #Act
62+ response = create_model (Goal , request_body )
63+
64+ #Assert
65+ assert response [0 ]["id" ] == 1 #create_model returns a tuple
66+ assert response [0 ]["title" ] == "Seize the Day!"
67+ assert response [1 ] == 201
0 commit comments