@@ -208,19 +208,21 @@ def unicode_emojis():
208
208
])
209
209
210
210
211
- def display_recipient_factory ( recipient_id : Optional [ int ] = None ,
212
- recipient_name : str = "" ):
211
+ @ pytest . fixture
212
+ def display_recipient_factory ( ):
213
213
"""
214
214
Generate display_recipient field for (stream/PM/group) messages
215
215
FIXME: Refactor other tests to make this depend only on recipient_id.
216
216
"""
217
- return {
218
- 'id' : recipient_id ,
219
- 'is_mirror_dummy' : False ,
220
- 'full_name' : recipient_name ,
221
- 'short_name' : f'{ recipient_id } ' ,
222
- 'email' : f'user-{ recipient_id } @zulip.com' ,
223
- } if recipient_id else "PTEST"
217
+ def _factory (recipient_id : Optional [int ]= None , recipient_name : str = "" ):
218
+ return {
219
+ 'id' : recipient_id ,
220
+ 'is_mirror_dummy' : False ,
221
+ 'full_name' : recipient_name ,
222
+ 'short_name' : f'{ recipient_id } ' ,
223
+ 'email' : f'user-{ recipient_id } @zulip.com' ,
224
+ } if recipient_id else "PTEST"
225
+ return _factory
224
226
225
227
226
228
@pytest .fixture
@@ -256,15 +258,15 @@ def _factory(msg_id: int, msg_type: str, stream_id: Optional[int],
256
258
257
259
258
260
@pytest .fixture
259
- def stream_msg_template (msg_template_factory ):
261
+ def stream_msg_template (display_recipient_factory , msg_template_factory ):
260
262
recipient = display_recipient_factory ()
261
263
msg_template = msg_template_factory (
262
264
537286 , 'stream' , 205 , 1520918722 , recipient )
263
265
return msg_template
264
266
265
267
266
268
@pytest .fixture
267
- def pm_template (msg_template_factory ):
269
+ def pm_template (display_recipient_factory , msg_template_factory ):
268
270
recipients = [display_recipient_factory (_id , name ) for _id , name in
269
271
{(5179 , 'Boo Boo' ), (5140 , 'Foo Foo' )}]
270
272
msg_template = msg_template_factory (
@@ -273,7 +275,7 @@ def pm_template(msg_template_factory):
273
275
274
276
275
277
@pytest .fixture
276
- def group_pm_template (msg_template_factory ):
278
+ def group_pm_template (display_recipient_factory , msg_template_factory ):
277
279
recipients = [display_recipient_factory (_id , name ) for _id , name in
278
280
{(5179 , 'Boo Boo' ), (5140 , 'Foo Foo' ), (5180 , 'Bar Bar' )}]
279
281
msg_template = msg_template_factory (
0 commit comments