@@ -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,49 @@ 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
+ '@H' , '@Hu' , '@Hum' , '@Huma' , '@Human' ,
247
+ '@**' , '@**H' , '@**Hu' , '@**Hum' , '@**Huma' , '@**Human'
248
+ ])
249
+ @pytest .mark .parametrize ('matching_users, distinct_matching_users' , [
250
+ (['Human Myself' , 'Human 1' , 'Human 2' , 'Human Duplicate' ,
251
+ 'Human Duplicate' ],
252
+ ['@**Human Myself**' , '@**Human 1**' , '@**Human 2**' ,
253
+ '@**Human Duplicate|13**' , '@**Human Duplicate|14**' ])
254
+ ])
255
+ def test_generic_autocomplete_user_mentions (self , write_box , text , mocker ,
256
+ distinct_matching_users ,
257
+ matching_users , state = 1 ):
258
+ _process_typeaheads = mocker .patch (BOXES
259
+ + '.WriteBox._process_typeaheads' )
260
+
261
+ write_box .generic_autocomplete (text , state )
262
+
263
+ _process_typeaheads .assert_called_once_with (distinct_matching_users ,
264
+ state , matching_users )
265
+
266
+ @pytest .mark .parametrize ('text' , [
267
+ '@_' , '@_H' , '@_Hu' , '@_Hum' , '@_Huma' , '@_Human'
268
+ ])
269
+ @pytest .mark .parametrize ('matching_users, distinct_matching_users' , [
270
+ (['Human Myself' , 'Human 1' , 'Human 2' , 'Human Duplicate' ,
271
+ 'Human Duplicate' ],
272
+ ['@_**Human Myself**' , '@_**Human 1**' , '@_**Human 2**' ,
273
+ '@_**Human Duplicate|13**' , '@_**Human Duplicate|14**' ])
274
+ ])
275
+ def test_generic_autocomplete_silent_user_mentions (self , write_box , text ,
276
+ mocker ,
277
+ matching_users ,
278
+ distinct_matching_users ,
279
+ state = 1 ):
280
+ _process_typeaheads = mocker .patch (BOXES
281
+ + '.WriteBox._process_typeaheads' )
282
+
283
+ write_box .generic_autocomplete (text , state )
284
+
285
+ _process_typeaheads .assert_called_once_with (distinct_matching_users ,
286
+ state , matching_users )
287
+
245
288
@pytest .mark .parametrize ('text, state, required_typeahead, to_pin' , [
246
289
# With no streams pinned.
247
290
('#Stream' , 0 , '#**Stream 1**' , []), # 1st-word startswith match.
0 commit comments