7
7
from time_tracker .projects ._application import _projects as azure_projects
8
8
from time_tracker .projects import _domain as domain
9
9
from time_tracker .projects import _infrastructure as infrastructure
10
- from time_tracker ._infrastructure import DB
11
10
12
11
PROJECT_URL = '/api/projects/'
13
12
14
13
15
14
@pytest .fixture (name = 'insert_project' )
16
- def _insert_project () -> domain .Project :
17
- def _new_project (project : domain .Project , database : DB ):
18
- dao = infrastructure .ProjectsSQLDao (database )
19
- new_project = dao .create (project )
20
- return new_project
15
+ def insert_project (test_db , insert_customer , project_factory , customer_factory ) -> domain .Project :
16
+ inserted_customer = insert_customer (customer_factory (), test_db )
17
+
18
+ def _new_project ():
19
+ project_to_insert = project_factory (customer_id = inserted_customer .id )
20
+ dao = infrastructure .ProjectsSQLDao (test_db )
21
+ inserted_project = dao .create (project_to_insert )
22
+ return inserted_project
21
23
return _new_project
22
24
23
25
24
26
def test__project_azure_endpoint__returns_all_projects (
25
- test_db , project_factory , insert_project , insert_customer , customer_factory
27
+ insert_project
26
28
):
27
- inserted_customer = insert_customer (customer_factory (), test_db )
28
- project_to_insert = [project_factory (customer_id = inserted_customer .id ),
29
- project_factory (customer_id = inserted_customer .id )]
30
29
inserted_projects = [
31
- insert_project (project_to_insert [ 0 ], test_db ).__dict__ ,
32
- insert_project (project_to_insert [ 1 ], test_db ).__dict__
30
+ insert_project ().__dict__ ,
31
+ insert_project ().__dict__
33
32
]
34
33
35
34
req = func .HttpRequest (method = 'GET' , body = None , url = PROJECT_URL )
@@ -41,11 +40,9 @@ def test__project_azure_endpoint__returns_all_projects(
41
40
42
41
43
42
def test__project_azure_endpoint__returns_an_project__when_project_matches_its_id (
44
- test_db , project_factory , insert_project , insert_customer , customer_factory
43
+ insert_project
45
44
):
46
- inserted_customer = insert_customer (customer_factory (), test_db )
47
- project_to_insert = project_factory (customer_id = inserted_customer .id )
48
- inserted_project = insert_project (project_to_insert , test_db ).__dict__
45
+ inserted_project = insert_project ().__dict__
49
46
50
47
req = func .HttpRequest (
51
48
method = 'GET' ,
@@ -77,11 +74,9 @@ def test__projects_azure_endpoint__returns_a_status_code_400__when_project_reciv
77
74
78
75
79
76
def test__project_azure_endpoint__returns_an_project_with_inactive_status__when_an_project_matching_its_id_is_found (
80
- test_db , project_factory , insert_project , insert_customer , customer_factory
77
+ insert_project
81
78
):
82
- inserted_customer = insert_customer (customer_factory (), test_db )
83
- project_to_insert = project_factory (customer_id = inserted_customer .id )
84
- inserted_project = insert_project (project_to_insert , test_db ).__dict__
79
+ inserted_project = insert_project ().__dict__
85
80
86
81
req = func .HttpRequest (
87
82
method = 'DELETE' ,
@@ -114,11 +109,9 @@ def test__delete_projects_azure_endpoint__returns_a_status_code_400__when_projec
114
109
115
110
116
111
def test__update_project_azure_endpoint__returns_an_project__when_found_an_project_to_update (
117
- test_db , project_factory , insert_project , insert_customer , customer_factory
112
+ insert_project
118
113
):
119
- inserted_customer = insert_customer (customer_factory (), test_db )
120
- project_to_insert = project_factory (customer_id = inserted_customer .id )
121
- inserted_project = insert_project (project_to_insert , test_db ).__dict__
114
+ inserted_project = insert_project ().__dict__
122
115
123
116
project_body = {"description" : Faker ().sentence ()}
124
117
req = func .HttpRequest (
0 commit comments