20
20
BugzillaWebhookRequest ,
21
21
)
22
22
from jbi .services import bugzilla , jira
23
- from tests .fixtures .factories import (
24
- action_context_factory ,
25
- action_factory ,
26
- bug_factory ,
27
- jira_context_factory ,
28
- webhook_event_factory ,
29
- webhook_factory ,
30
- webhook_user_factory ,
31
- )
23
+ from tests .fixtures import factories
32
24
33
25
34
26
@pytest .fixture (autouse = True )
@@ -85,25 +77,29 @@ def mocked_responses():
85
77
86
78
@pytest .fixture
87
79
def context_create_example () -> ActionContext :
88
- return action_context_factory (
80
+ return factories . action_context_factory (
89
81
operation = Operation .CREATE ,
90
82
)
91
83
92
84
93
85
@pytest .fixture
94
86
def context_update_example () -> ActionContext :
95
- bug = bug_factory (see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ])
96
- context = action_context_factory (
87
+ bug = factories .bug_factory (
88
+ see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ]
89
+ )
90
+ context = factories .action_context_factory (
97
91
operation = Operation .UPDATE ,
98
92
bug = bug ,
99
- jira = jira_context_factory (issue = bug .extract_from_see_also ()),
93
+ jira = factories . jira_context_factory (issue = bug .extract_from_see_also ()),
100
94
)
101
95
return context
102
96
103
97
104
98
@pytest .fixture
105
99
def context_update_status_assignee () -> ActionContext :
106
- bug = bug_factory (see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ])
100
+ bug = factories .bug_factory (
101
+ see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ]
102
+ )
107
103
changes = [
108
104
{
109
105
"field" : "status" ,
@@ -116,84 +112,88 @@ def context_update_status_assignee() -> ActionContext:
116
112
117
113
},
118
114
]
119
- event = webhook_event_factory (routing_key = "bug.modify" , changes = changes )
120
- context = action_context_factory (
115
+ event = factories . webhook_event_factory (routing_key = "bug.modify" , changes = changes )
116
+ context = factories . action_context_factory (
121
117
operation = Operation .UPDATE ,
122
118
bug = bug ,
123
119
event = event ,
124
- jira = jira_context_factory (issue = bug .extract_from_see_also ()),
120
+ jira = factories . jira_context_factory (issue = bug .extract_from_see_also ()),
125
121
)
126
122
return context
127
123
128
124
129
125
@pytest .fixture
130
126
def context_comment_example () -> ActionContext :
131
- user = webhook_user_factory (
login = "[email protected] " )
127
+ user = factories . webhook_user_factory (
login = "[email protected] " )
132
128
comment = BugzillaWebhookComment .parse_obj ({"number" : 2 , "body" : "hello" })
133
- bug = bug_factory (
129
+ bug = factories . bug_factory (
134
130
see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ],
135
131
comment = comment ,
136
132
)
137
- event = webhook_event_factory (target = "comment" , user = user )
138
- context = action_context_factory (
133
+ event = factories . webhook_event_factory (target = "comment" , user = user )
134
+ context = factories . action_context_factory (
139
135
operation = Operation .COMMENT ,
140
136
bug = bug ,
141
137
event = event ,
142
- jira = jira_context_factory (issue = bug .extract_from_see_also ()),
138
+ jira = factories . jira_context_factory (issue = bug .extract_from_see_also ()),
143
139
)
144
140
return context
145
141
146
142
147
143
@pytest .fixture
148
144
def context_update_resolution_example () -> ActionContext :
149
- bug = bug_factory (see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ])
150
- event = webhook_event_factory (action = "modify" , routing_key = "bug.modify:resolution" )
151
- context = action_context_factory (
145
+ bug = factories .bug_factory (
146
+ see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ]
147
+ )
148
+ event = factories .webhook_event_factory (
149
+ action = "modify" , routing_key = "bug.modify:resolution"
150
+ )
151
+ context = factories .action_context_factory (
152
152
operation = Operation .UPDATE ,
153
153
bug = bug ,
154
154
event = event ,
155
- jira = jira_context_factory (issue = bug .extract_from_see_also ()),
155
+ jira = factories . jira_context_factory (issue = bug .extract_from_see_also ()),
156
156
)
157
157
return context
158
158
159
159
160
160
@pytest .fixture
161
161
def webhook_create_example () -> BugzillaWebhookRequest :
162
- webhook_payload = webhook_factory ()
162
+ webhook_payload = factories . webhook_factory ()
163
163
164
164
return webhook_payload
165
165
166
166
167
167
@pytest .fixture
168
168
def webhook_comment_example () -> BugzillaWebhookRequest :
169
- user = webhook_user_factory (
login = "[email protected] " )
169
+ user = factories . webhook_user_factory (
login = "[email protected] " )
170
170
comment = BugzillaWebhookComment .parse_obj ({"number" : 2 , "body" : "hello" })
171
- bug = bug_factory (
171
+ bug = factories . bug_factory (
172
172
see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ],
173
173
comment = comment ,
174
174
)
175
- event = webhook_event_factory (target = "comment" , user = user )
176
- webhook_payload = webhook_factory (bug = bug , event = event )
175
+ event = factories . webhook_event_factory (target = "comment" , user = user )
176
+ webhook_payload = factories . webhook_factory (bug = bug , event = event )
177
177
178
178
return webhook_payload
179
179
180
180
181
181
@pytest .fixture
182
182
def webhook_private_comment_example () -> BugzillaWebhookRequest :
183
- user = webhook_user_factory (
login = "[email protected] " )
184
- event = webhook_event_factory (target = "comment" , user = user )
185
- bug = bug_factory (
183
+ user = factories . webhook_user_factory (
login = "[email protected] " )
184
+ event = factories . webhook_event_factory (target = "comment" , user = user )
185
+ bug = factories . bug_factory (
186
186
comment = {"id" : 344 , "number" : 2 , "is_private" : True },
187
187
see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ],
188
188
)
189
- webhook_payload = webhook_factory (bug = bug , event = event )
189
+ webhook_payload = factories . webhook_factory (bug = bug , event = event )
190
190
return webhook_payload
191
191
192
192
193
193
@pytest .fixture
194
194
def webhook_create_private_example () -> BugzillaWebhookRequest :
195
- return webhook_factory (
196
- event = webhook_event_factory (),
195
+ return factories . webhook_factory (
196
+ event = factories . webhook_event_factory (),
197
197
bug = {"id" : 654321 , "is_private" : True },
198
198
)
199
199
@@ -212,23 +212,30 @@ def webhook_change_status_assignee():
212
212
213
213
},
214
214
]
215
- event = webhook_event_factory (routing_key = "bug.modify" , changes = changes )
216
- webhook_payload = webhook_factory (event = event )
215
+ event = factories . webhook_event_factory (routing_key = "bug.modify" , changes = changes )
216
+ webhook_payload = factories . webhook_factory (event = event )
217
217
return webhook_payload
218
218
219
219
220
220
@pytest .fixture
221
221
def webhook_modify_private_example () -> BugzillaWebhookRequest :
222
- event = webhook_event_factory (action = "modify" , routing_key = "bug.modify:status" )
223
- webhook_payload = webhook_factory (
222
+ event = factories .webhook_event_factory (
223
+ action = "modify" , routing_key = "bug.modify:status"
224
+ )
225
+ webhook_payload = factories .webhook_factory (
224
226
bug = {"id" : 654321 , "is_private" : True }, event = event
225
227
)
226
228
return webhook_payload
227
229
228
230
231
+ @pytest .fixture
232
+ def action_factory () -> Action :
233
+ return factories .action_factory
234
+
235
+
229
236
@pytest .fixture
230
237
def action_example () -> Action :
231
- return action_factory ()
238
+ return factories . action_factory ()
232
239
233
240
234
241
@pytest .fixture
0 commit comments