2020    BugzillaWebhookRequest ,
2121)
2222from  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 
3224
3325
3426@pytest .fixture (autouse = True ) 
@@ -85,25 +77,29 @@ def mocked_responses():
8577
8678@pytest .fixture  
8779def  context_create_example () ->  ActionContext :
88-     return  action_context_factory (
80+     return  factories . action_context_factory (
8981        operation = Operation .CREATE ,
9082    )
9183
9284
9385@pytest .fixture  
9486def  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 (
9791        operation = Operation .UPDATE ,
9892        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 ()),
10094    )
10195    return  context 
10296
10397
10498@pytest .fixture  
10599def  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+     )
107103    changes  =  [
108104        {
109105            "field" : "status" ,
@@ -116,84 +112,88 @@ def context_update_status_assignee() -> ActionContext:
116112117113        },
118114    ]
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 (
121117        operation = Operation .UPDATE ,
122118        bug = bug ,
123119        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 ()),
125121    )
126122    return  context 
127123
128124
129125@pytest .fixture  
130126def  context_comment_example () ->  ActionContext :
131-     user  =  webhook_user_factory (
login = "[email protected] " )
 127+     user  =  factories . webhook_user_factory (
login = "[email protected] " )
 132128    comment  =  BugzillaWebhookComment .parse_obj ({"number" : 2 , "body" : "hello" })
133-     bug  =  bug_factory (
129+     bug  =  factories . bug_factory (
134130        see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ],
135131        comment = comment ,
136132    )
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 (
139135        operation = Operation .COMMENT ,
140136        bug = bug ,
141137        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 ()),
143139    )
144140    return  context 
145141
146142
147143@pytest .fixture  
148144def  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 (
152152        operation = Operation .UPDATE ,
153153        bug = bug ,
154154        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 ()),
156156    )
157157    return  context 
158158
159159
160160@pytest .fixture  
161161def  webhook_create_example () ->  BugzillaWebhookRequest :
162-     webhook_payload  =  webhook_factory ()
162+     webhook_payload  =  factories . webhook_factory ()
163163
164164    return  webhook_payload 
165165
166166
167167@pytest .fixture  
168168def  webhook_comment_example () ->  BugzillaWebhookRequest :
169-     user  =  webhook_user_factory (
login = "[email protected] " )
 169+     user  =  factories . webhook_user_factory (
login = "[email protected] " )
 170170    comment  =  BugzillaWebhookComment .parse_obj ({"number" : 2 , "body" : "hello" })
171-     bug  =  bug_factory (
171+     bug  =  factories . bug_factory (
172172        see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ],
173173        comment = comment ,
174174    )
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 )
177177
178178    return  webhook_payload 
179179
180180
181181@pytest .fixture  
182182def  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 (
186186        comment = {"id" : 344 , "number" : 2 , "is_private" : True },
187187        see_also = ["https://mozilla.atlassian.net/browse/JBI-234" ],
188188    )
189-     webhook_payload  =  webhook_factory (bug = bug , event = event )
189+     webhook_payload  =  factories . webhook_factory (bug = bug , event = event )
190190    return  webhook_payload 
191191
192192
193193@pytest .fixture  
194194def  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 (),
197197        bug = {"id" : 654321 , "is_private" : True },
198198    )
199199
@@ -212,23 +212,30 @@ def webhook_change_status_assignee():
212212213213        },
214214    ]
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 )
217217    return  webhook_payload 
218218
219219
220220@pytest .fixture  
221221def  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 (
224226        bug = {"id" : 654321 , "is_private" : True }, event = event 
225227    )
226228    return  webhook_payload 
227229
228230
231+ @pytest .fixture  
232+ def  action_factory () ->  Action :
233+     return  factories .action_factory 
234+ 
235+ 
229236@pytest .fixture  
230237def  action_example () ->  Action :
231-     return  action_factory ()
238+     return  factories . action_factory ()
232239
233240
234241@pytest .fixture  
0 commit comments