@@ -128,19 +128,19 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
128
128
('@Human' , 0 , '@**Human Myself**' ),
129
129
('@Human' , 1 , '@**Human 1**' ),
130
130
('@Human' , 2 , '@**Human 2**' ),
131
- ('@Human' , 3 , '@**Human Duplicate**' ),
132
- ('@Human' , 4 , '@**Human Duplicate**' ),
133
- ('@Human' , - 1 , '@**Human Duplicate**' ),
134
- ('@Human' , - 2 , '@**Human Duplicate**' ),
131
+ ('@Human' , 3 , '@**Human Duplicate|13 **' ),
132
+ ('@Human' , 4 , '@**Human Duplicate|14 **' ),
133
+ ('@Human' , - 1 , '@**Human Duplicate|14 **' ),
134
+ ('@Human' , - 2 , '@**Human Duplicate|13 **' ),
135
135
('@Human' , - 3 , '@**Human 2**' ),
136
136
('@Human' , - 4 , '@**Human 1**' ),
137
137
('@Human' , - 5 , '@**Human Myself**' ),
138
138
('@Human' , - 6 , None ),
139
139
('@_Human' , 0 , '@_**Human Myself**' ),
140
140
('@_Human' , 1 , '@_**Human 1**' ),
141
141
('@_Human' , 2 , '@_**Human 2**' ),
142
- ('@_Human' , 3 , '@_**Human Duplicate**' ),
143
- ('@_Human' , 4 , '@_**Human Duplicate**' ),
142
+ ('@_Human' , 3 , '@_**Human Duplicate|13 **' ),
143
+ ('@_Human' , 4 , '@_**Human Duplicate|14 **' ),
144
144
('@H' , 1 , '@**Human 1**' ),
145
145
('@Hu' , 1 , '@**Human 1**' ),
146
146
('@Hum' , 1 , '@**Human 1**' ),
@@ -167,8 +167,8 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
167
167
('@' , 0 , '@**Human Myself**' ),
168
168
('@' , 1 , '@**Human 1**' ),
169
169
('@' , 2 , '@**Human 2**' ),
170
- ('@' , 3 , '@**Human Duplicate**' ),
171
- ('@' , 4 , '@**Human Duplicate**' ),
170
+ ('@' , 3 , '@**Human Duplicate|13 **' ),
171
+ ('@' , 4 , '@**Human Duplicate|14 **' ),
172
172
('@' , 5 , '@*Group 1*' ),
173
173
('@' , 6 , '@*Group 2*' ),
174
174
('@' , 7 , '@*Group 3*' ),
@@ -179,8 +179,8 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
179
179
('@**' , 0 , '@**Human Myself**' ),
180
180
('@**' , 1 , '@**Human 1**' ),
181
181
('@**' , 2 , '@**Human 2**' ),
182
- ('@' , 3 , '@**Human Duplicate**' ),
183
- ('@' , 4 , '@**Human Duplicate**' ),
182
+ ('@' , 3 , '@**Human Duplicate|13 **' ),
183
+ ('@' , 4 , '@**Human Duplicate|14 **' ),
184
184
('@**' , 5 , None ), # Reached last match
185
185
('@**' , 6 , None ), # Beyond end
186
186
# Expected sequence of autocompletes from '@*' (only groups)
@@ -194,11 +194,11 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
194
194
('@_' , 0 , '@_**Human Myself**' ), # NOTE: No silent group mention
195
195
('@_' , 1 , '@_**Human 1**' ),
196
196
('@_' , 2 , '@_**Human 2**' ),
197
- ('@_' , 3 , '@_**Human Duplicate**' ),
198
- ('@_' , 4 , '@_**Human Duplicate**' ),
197
+ ('@_' , 3 , '@_**Human Duplicate|13 **' ),
198
+ ('@_' , 4 , '@_**Human Duplicate|14 **' ),
199
199
('@_' , 5 , None ), # Reached last match
200
200
('@_' , 6 , None ), # Beyond end
201
- ('@_' , - 1 , '@_**Human Duplicate**' ),
201
+ ('@_' , - 1 , '@_**Human Duplicate|14 **' ),
202
202
# Complex autocomplete prefixes.
203
203
('(@H' , 0 , '(@**Human Myself**' ),
204
204
('(@H' , 1 , '(@**Human 1**' ),
@@ -242,6 +242,51 @@ def test_generic_autocomplete_mentions_subscribers(self, write_box, text,
242
242
typeahead_string = write_box .generic_autocomplete (text , state )
243
243
assert typeahead_string == required_typeahead
244
244
245
+ @pytest .mark .parametrize ('text' , [
246
+ prefix + 'Human' [:index + 1 ] for index in range (len ('Human' ))
247
+ for prefix in ['@' , '@**' ]
248
+ ] + ['@**' ])
249
+ def test_generic_autocomplete_user_mentions (self , write_box , text , mocker ,
250
+ state = 1 ):
251
+ _process_typeaheads = mocker .patch (BOXES
252
+ + '.WriteBox._process_typeaheads' )
253
+
254
+ matching_users = [
255
+ 'Human Myself' , 'Human 1' , 'Human 2' , 'Human Duplicate' ,
256
+ 'Human Duplicate' ,
257
+ ]
258
+ distinct_matching_users = [
259
+ '@**Human Myself**' , '@**Human 1**' , '@**Human 2**' ,
260
+ '@**Human Duplicate|13**' , '@**Human Duplicate|14**' ,
261
+ ]
262
+
263
+ write_box .generic_autocomplete (text , state )
264
+
265
+ _process_typeaheads .assert_called_once_with (distinct_matching_users ,
266
+ state , matching_users )
267
+
268
+ @pytest .mark .parametrize ('text' , [
269
+ '@_' + 'Human' [:index ] for index in range (len ('Human' ) + 1 )
270
+ ])
271
+ def test_generic_autocomplete_silent_user_mentions (self , write_box , text ,
272
+ mocker , state = 1 ):
273
+ _process_typeaheads = mocker .patch (BOXES
274
+ + '.WriteBox._process_typeaheads' )
275
+
276
+ matching_users = [
277
+ 'Human Myself' , 'Human 1' , 'Human 2' , 'Human Duplicate' ,
278
+ 'Human Duplicate' ,
279
+ ]
280
+ distinct_matching_users = [
281
+ '@_**Human Myself**' , '@_**Human 1**' , '@_**Human 2**' ,
282
+ '@_**Human Duplicate|13**' , '@_**Human Duplicate|14**' ,
283
+ ]
284
+
285
+ write_box .generic_autocomplete (text , state )
286
+
287
+ _process_typeaheads .assert_called_once_with (distinct_matching_users ,
288
+ state , matching_users )
289
+
245
290
@pytest .mark .parametrize ('text, state, required_typeahead, to_pin' , [
246
291
# With no streams pinned.
247
292
('#Stream' , 0 , '#**Stream 1**' , []), # 1st-word startswith match.
0 commit comments