@@ -221,19 +221,19 @@ def test_generic_autocomplete_set_footer(
221
221
("@Human" , 0 , "@**Human Myself**" ),
222
222
("@Human" , 1 , "@**Human 1**" ),
223
223
("@Human" , 2 , "@**Human 2**" ),
224
- ("@Human" , 3 , "@**Human Duplicate**" ),
225
- ("@Human" , 4 , "@**Human Duplicate**" ),
226
- ("@Human" , - 1 , "@**Human Duplicate**" ),
227
- ("@Human" , - 2 , "@**Human Duplicate**" ),
224
+ ("@Human" , 3 , "@**Human Duplicate|13 **" ),
225
+ ("@Human" , 4 , "@**Human Duplicate|14 **" ),
226
+ ("@Human" , - 1 , "@**Human Duplicate|14 **" ),
227
+ ("@Human" , - 2 , "@**Human Duplicate|13 **" ),
228
228
("@Human" , - 3 , "@**Human 2**" ),
229
229
("@Human" , - 4 , "@**Human 1**" ),
230
230
("@Human" , - 5 , "@**Human Myself**" ),
231
231
("@Human" , - 6 , None ),
232
232
("@_Human" , 0 , "@_**Human Myself**" ),
233
233
("@_Human" , 1 , "@_**Human 1**" ),
234
234
("@_Human" , 2 , "@_**Human 2**" ),
235
- ("@_Human" , 3 , "@_**Human Duplicate**" ),
236
- ("@_Human" , 4 , "@_**Human Duplicate**" ),
235
+ ("@_Human" , 3 , "@_**Human Duplicate|13 **" ),
236
+ ("@_Human" , 4 , "@_**Human Duplicate|14 **" ),
237
237
("@H" , 1 , "@**Human 1**" ),
238
238
("@Hu" , 1 , "@**Human 1**" ),
239
239
("@Hum" , 1 , "@**Human 1**" ),
@@ -260,8 +260,8 @@ def test_generic_autocomplete_set_footer(
260
260
("@" , 0 , "@**Human Myself**" ),
261
261
("@" , 1 , "@**Human 1**" ),
262
262
("@" , 2 , "@**Human 2**" ),
263
- ("@" , 3 , "@**Human Duplicate**" ),
264
- ("@" , 4 , "@**Human Duplicate**" ),
263
+ ("@" , 3 , "@**Human Duplicate|13 **" ),
264
+ ("@" , 4 , "@**Human Duplicate|14 **" ),
265
265
("@" , 5 , "@*Group 1*" ),
266
266
("@" , 6 , "@*Group 2*" ),
267
267
("@" , 7 , "@*Group 3*" ),
@@ -272,8 +272,8 @@ def test_generic_autocomplete_set_footer(
272
272
("@**" , 0 , "@**Human Myself**" ),
273
273
("@**" , 1 , "@**Human 1**" ),
274
274
("@**" , 2 , "@**Human 2**" ),
275
- ("@" , 3 , "@**Human Duplicate**" ),
276
- ("@" , 4 , "@**Human Duplicate**" ),
275
+ ("@" , 3 , "@**Human Duplicate|13 **" ),
276
+ ("@" , 4 , "@**Human Duplicate|14 **" ),
277
277
("@**" , 5 , None ), # Reached last match
278
278
("@**" , 6 , None ), # Beyond end
279
279
# Expected sequence of autocompletes from '@*' (only groups)
@@ -287,11 +287,11 @@ def test_generic_autocomplete_set_footer(
287
287
("@_" , 0 , "@_**Human Myself**" ), # NOTE: No silent group mention
288
288
("@_" , 1 , "@_**Human 1**" ),
289
289
("@_" , 2 , "@_**Human 2**" ),
290
- ("@_" , 3 , "@_**Human Duplicate**" ),
291
- ("@_" , 4 , "@_**Human Duplicate**" ),
290
+ ("@_" , 3 , "@_**Human Duplicate|13 **" ),
291
+ ("@_" , 4 , "@_**Human Duplicate|14 **" ),
292
292
("@_" , 5 , None ), # Reached last match
293
293
("@_" , 6 , None ), # Beyond end
294
- ("@_" , - 1 , "@_**Human Duplicate**" ),
294
+ ("@_" , - 1 , "@_**Human Duplicate|14 **" ),
295
295
# Complex autocomplete prefixes.
296
296
("(@H" , 0 , "(@**Human Myself**" ),
297
297
("(@H" , 1 , "(@**Human 1**" ),
@@ -340,6 +340,68 @@ def test_generic_autocomplete_mentions_subscribers(
340
340
typeahead_string = write_box .generic_autocomplete (text , state )
341
341
assert typeahead_string == required_typeahead
342
342
343
+ @pytest .mark .parametrize (
344
+ "text" ,
345
+ [
346
+ prefix + "Human" [: index + 1 ]
347
+ for index in range (len ("Human" ))
348
+ for prefix in ["@" , "@**" ]
349
+ ]
350
+ + ["@**" ],
351
+ )
352
+ def test_generic_autocomplete_user_mentions (self , write_box , text , mocker , state = 1 ):
353
+ _process_typeaheads = mocker .patch (BOXES + ".WriteBox._process_typeaheads" )
354
+
355
+ matching_users = [
356
+ "Human Myself" ,
357
+ "Human 1" ,
358
+ "Human 2" ,
359
+ "Human Duplicate" ,
360
+ "Human Duplicate" ,
361
+ ]
362
+ distinct_matching_users = [
363
+ "@**Human Myself**" ,
364
+ "@**Human 1**" ,
365
+ "@**Human 2**" ,
366
+ "@**Human Duplicate|13**" ,
367
+ "@**Human Duplicate|14**" ,
368
+ ]
369
+
370
+ write_box .generic_autocomplete (text , state )
371
+
372
+ _process_typeaheads .assert_called_once_with (
373
+ distinct_matching_users , state , matching_users
374
+ )
375
+
376
+ @pytest .mark .parametrize (
377
+ "text" , ["@_" + "Human" [:index ] for index in range (len ("Human" ) + 1 )]
378
+ )
379
+ def test_generic_autocomplete_silent_user_mentions (
380
+ self , write_box , text , mocker , state = 1
381
+ ):
382
+ _process_typeaheads = mocker .patch (BOXES + ".WriteBox._process_typeaheads" )
383
+
384
+ matching_users = [
385
+ "Human Myself" ,
386
+ "Human 1" ,
387
+ "Human 2" ,
388
+ "Human Duplicate" ,
389
+ "Human Duplicate" ,
390
+ ]
391
+ distinct_matching_users = [
392
+ "@_**Human Myself**" ,
393
+ "@_**Human 1**" ,
394
+ "@_**Human 2**" ,
395
+ "@_**Human Duplicate|13**" ,
396
+ "@_**Human Duplicate|14**" ,
397
+ ]
398
+
399
+ write_box .generic_autocomplete (text , state )
400
+
401
+ _process_typeaheads .assert_called_once_with (
402
+ distinct_matching_users , state , matching_users
403
+ )
404
+
343
405
@pytest .mark .parametrize (
344
406
"text, state, required_typeahead, to_pin" ,
345
407
[
0 commit comments