@@ -43,7 +43,8 @@ def collection(branch_data, collection_without_branch) -> DesignWorkflowCollecti
43
43
44
44
@pytest .fixture
45
45
def workflow (collection , branch_data , design_workflow_dict ) -> DesignWorkflow :
46
- design_workflow_dict ["branch_id" ] = branch_data ["id" ]
46
+ design_workflow_dict ["branch_root_id" ] = branch_data ["metadata" ]["root_id" ]
47
+ design_workflow_dict ["branch_version" ] = branch_data ["metadata" ]["version" ]
47
48
48
49
collection .session .set_response (branch_data )
49
50
workflow = collection .build (design_workflow_dict )
@@ -71,12 +72,6 @@ def workflow_path(collection, workflow=None):
71
72
path = f'{ path } /{ workflow .uid } '
72
73
return path
73
74
74
- def branches_path (collection , branch_id = None ):
75
- path = f'/projects/{ collection .project_id } /branches'
76
- if branch_id :
77
- path = f'{ path } /{ branch_id } '
78
- return path
79
-
80
75
def assert_workflow (actual , expected , * , include_branch = False ):
81
76
assert actual .name == expected .name
82
77
assert actual .description == expected .description
@@ -86,7 +81,7 @@ def assert_workflow(actual, expected, *, include_branch=False):
86
81
assert actual .predictor_version == expected .predictor_version
87
82
assert actual .project_id == expected .project_id
88
83
if include_branch :
89
- assert actual .branch_id == expected .branch_id
84
+ assert actual ._branch_id == expected ._branch_id
90
85
assert actual .branch_root_id == expected .branch_root_id
91
86
assert actual .branch_version == expected .branch_version
92
87
@@ -99,29 +94,22 @@ def test_basic_methods(workflow, collection, design_workflow_dict):
99
94
@pytest .mark .parametrize ("optional_args" , all_combination_lengths (OPTIONAL_ARGS ))
100
95
def test_register (session , branch_data , workflow_minimal , collection , optional_args ):
101
96
workflow = workflow_minimal
102
- branch_id = branch_data ['id' ]
103
- branch_data_get_resp = {"response" : [branch_data ]}
104
- branch_data_get_params = {
105
- 'page' : 1 , 'per_page' : 1 , 'root' : str (collection .branch_root_id ), 'version' : collection .branch_version
106
- }
97
+ branch_root_id = branch_data ['metadata' ]['root_id' ]
98
+ branch_version = branch_data ['metadata' ]['version' ]
107
99
108
100
# Set a random value for all optional args selected for this run.
109
101
for name , factory in optional_args :
110
102
setattr (workflow , name , factory ())
111
103
112
104
# Given
113
- post_dict = {** workflow .dump (), "branch_id " : str (branch_id ) }
114
- session .set_responses (branch_data_get_resp , {** post_dict , 'status_description' : 'status' }, branch_data )
105
+ post_dict = {** workflow .dump (), "branch_root_id " : str (branch_root_id ), "branch_version" : branch_version }
106
+ session .set_responses ({** post_dict , 'status_description' : 'status' })
115
107
116
108
# When
117
109
new_workflow = collection .register (workflow )
118
110
119
111
# Then
120
- assert session .calls == [
121
- FakeCall (method = 'GET' , path = branches_path (collection ), params = branch_data_get_params ),
122
- FakeCall (method = 'POST' , path = workflow_path (collection ), json = post_dict ),
123
- FakeCall (method = 'GET' , path = branches_path (collection , branch_id )),
124
- ]
112
+ assert session .calls == [FakeCall (method = 'POST' , path = workflow_path (collection ), json = post_dict )]
125
113
126
114
assert new_workflow .branch_root_id == collection .branch_root_id
127
115
assert new_workflow .branch_version == collection .branch_version
@@ -133,23 +121,18 @@ def test_register_conflicting_branches(session, branch_data, workflow, collectio
133
121
old_branch_root_id = uuid .uuid4 ()
134
122
workflow .branch_root_id = old_branch_root_id
135
123
assert workflow .branch_root_id != collection .branch_root_id
124
+
125
+ new_branch_root_id = str (branch_data ["metadata" ]["root_id" ])
126
+ new_branch_version = branch_data ["metadata" ]["version" ]
136
127
137
- branch_data_get_resp = {"response" : [branch_data ]}
138
- branch_data_get_params = {
139
- 'page' : 1 , 'per_page' : 1 , 'root' : str (collection .branch_root_id ), 'version' : collection .branch_version
140
- }
141
- post_dict = {** workflow .dump (), "branch_id" : str (branch_data ["id" ])}
142
- session .set_responses (branch_data_get_resp , {** post_dict , 'status_description' : 'status' }, branch_data )
128
+ post_dict = {** workflow .dump (), "branch_root_id" : new_branch_root_id , "branch_version" : new_branch_version }
129
+ session .set_responses ({** post_dict , 'status_description' : 'status' })
143
130
144
131
# When
145
132
new_workflow = collection .register (workflow )
146
133
147
134
# Then
148
- assert session .calls == [
149
- FakeCall (method = 'GET' , path = branches_path (collection ), params = branch_data_get_params ),
150
- FakeCall (method = 'POST' , path = workflow_path (collection ), json = post_dict ),
151
- FakeCall (method = 'GET' , path = branches_path (collection , branch_data ["id" ])),
152
- ]
135
+ assert session .calls == [FakeCall (method = 'POST' , path = workflow_path (collection ), json = post_dict )]
153
136
154
137
assert workflow .branch_root_id == old_branch_root_id
155
138
assert new_workflow .branch_root_id == collection .branch_root_id
@@ -180,10 +163,10 @@ def test_delete(collection):
180
163
181
164
182
165
def test_list_archived (branch_data , workflow , collection : DesignWorkflowCollection ):
183
- branch_data_get_resp = { "response" : [ branch_data ]}
184
- branch_id = uuid . UUID ( branch_data ['id' ])
166
+ branch_root_id = uuid . UUID ( branch_data [ 'metadata' ][ 'root_id' ])
167
+ branch_version = branch_data ['metadata' ][ 'version' ]
185
168
186
- collection .session .set_responses (branch_data_get_resp , {"response" : []})
169
+ collection .session .set_responses ({"response" : []})
187
170
188
171
lst = list (collection .list_archived (per_page = 10 ))
189
172
assert len (lst ) == 0
@@ -192,7 +175,7 @@ def test_list_archived(branch_data, workflow, collection: DesignWorkflowCollecti
192
175
assert collection .session .last_call == FakeCall (
193
176
method = 'GET' ,
194
177
path = expected_path ,
195
- params = {'page' : 1 , 'per_page' : 10 , 'filter' : "archived eq 'true'" , 'branch ' : branch_id },
178
+ params = {'page' : 1 , 'per_page' : 10 , 'filter' : "archived eq 'true'" , 'branch_root_id ' : branch_root_id , 'branch_version' : branch_version },
196
179
json = None
197
180
)
198
181
@@ -213,17 +196,10 @@ def test_missing_project(design_workflow_dict):
213
196
214
197
def test_update (session , branch_data , workflow , collection_without_branch ):
215
198
# Given
216
- branch_data_get_resp = {"response" : [branch_data ]}
217
- branch_data_get_params = {
218
- 'page' : 1 , 'per_page' : 1 , 'root' : str (workflow .branch_root_id ), 'version' : workflow .branch_version
219
- }
220
-
221
199
post_dict = workflow .dump ()
222
200
session .set_responses (
223
- branch_data_get_resp ,
224
201
{"per_page" : 1 , "next" : "" , "response" : []},
225
202
{** post_dict , 'status_description' : 'status' },
226
- branch_data
227
203
)
228
204
229
205
# When
@@ -232,20 +208,16 @@ def test_update(session, branch_data, workflow, collection_without_branch):
232
208
# Then
233
209
executions_path = f'/projects/{ collection_without_branch .project_id } /design-workflows/{ workflow .uid } /executions'
234
210
assert session .calls == [
235
- FakeCall (method = 'GET' , path = branches_path (collection_without_branch ), params = branch_data_get_params ),
236
211
FakeCall (method = 'GET' , path = executions_path , params = {'page' : 1 , 'per_page' : 100 }),
237
212
FakeCall (method = 'PUT' , path = workflow_path (collection_without_branch , workflow ), json = post_dict ),
238
- FakeCall (method = 'GET' , path = branches_path (collection_without_branch , branch_data ["id" ])),
239
213
]
240
214
assert_workflow (new_workflow , workflow )
241
215
242
216
243
217
def test_update_failure_with_existing_execution (session , branch_data , workflow , collection_without_branch , design_execution_dict ):
244
- branch_data_get_resp = {"response" : [branch_data ]}
245
218
workflow .branch_root_id = uuid .uuid4 ()
246
219
post_dict = workflow .dump ()
247
220
session .set_responses (
248
- branch_data_get_resp ,
249
221
{"per_page" : 1 , "next" : "" , "response" : [design_execution_dict ]},
250
222
{** post_dict , 'status_description' : 'status' })
251
223
0 commit comments