Skip to content

Commit 07c4e75

Browse files
committed
tests: Introduce 'Human Duplicate' to test for users with the same name.
This commit adds two new users to the testing suite, both named 'Human Duplicate' as a prep commit for future tests that need such users. Tests updated (by adding test cases where relevant and extending existing parameters to include both these users in typeaheads and footer texts).
1 parent ff1d411 commit 07c4e75

File tree

2 files changed

+97
-29
lines changed

2 files changed

+97
-29
lines changed

tests/conftest.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ def users_fixture(logged_on_user):
9797
'is_bot': False,
9898
'is_admin': False,
9999
})
100+
# Also add two users with the same name.
101+
for i in range(1, 3):
102+
users.append({
103+
'user_id': 12 + i,
104+
'full_name': 'Human Duplicate',
105+
'email': f"personduplicate{i}@example.com",
106+
'avatar_url': None,
107+
'is_active': True,
108+
'bot_type': None,
109+
'is_bot': False,
110+
'is_admin': False,
111+
})
100112
return users
101113

102114

@@ -710,6 +722,18 @@ def user_dict(logged_on_user):
710722
'user_id': 12,
711723
'status': 'inactive'
712724
},
725+
726+
'full_name': 'Human Duplicate',
727+
'email': '[email protected]',
728+
'user_id': 13,
729+
'status': 'inactive'
730+
},
731+
732+
'full_name': 'Human Duplicate',
733+
'email': '[email protected]',
734+
'user_id': 14,
735+
'status': 'inactive'
736+
},
713737
714738
'email': '[email protected]',
715739
'full_name': 'Email Gateway',
@@ -764,6 +788,16 @@ def user_list(logged_on_user):
764788
'email': '[email protected]',
765789
'user_id': 12,
766790
'status': 'inactive'
791+
}, {
792+
'full_name': 'Human Duplicate',
793+
'email': '[email protected]',
794+
'user_id': 13,
795+
'status': 'inactive'
796+
}, {
797+
'full_name': 'Human Duplicate',
798+
'email': '[email protected]',
799+
'user_id': 14,
800+
'status': 'inactive'
767801
}, {
768802
'email': '[email protected]',
769803
'full_name': 'Notification Bot',

tests/ui_tools/test_boxes.py

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,23 @@ def test_generic_autocomplete_no_prefix(self, mocker, write_box, text,
8181
@pytest.mark.parametrize('text, state, footer_text', [
8282
# no-text mentions
8383
('@', 0,
84-
['Human Myself', 'Human 1', 'Human 2',
85-
'Group 1', 'Group 2', 'Group 3', 'Group 4']),
84+
['Human Myself', 'Human 1', 'Human 2', 'Human Duplicate',
85+
'Human Duplicate', 'Group 1', 'Group 2', 'Group 3', 'Group 4']),
8686
('@*', 0, ['Group 1', 'Group 2', 'Group 3', 'Group 4']),
87-
('@**', 0, ['Human Myself', 'Human 1', 'Human 2']),
87+
('@**', 0, ['Human Myself', 'Human 1', 'Human 2',
88+
'Human Duplicate', 'Human Duplicate']),
8889
# mentions
89-
('@Human', 0, ['Human Myself', 'Human 1', 'Human 2']),
90-
('@**Human', 0, ['Human Myself', 'Human 1', 'Human 2']),
91-
('@_Human', 0, ['Human Myself', 'Human 1', 'Human 2']),
90+
('@Human', 0, ['Human Myself', 'Human 1', 'Human 2',
91+
'Human Duplicate', 'Human Duplicate']),
92+
('@**Human', 0, ['Human Myself', 'Human 1', 'Human 2',
93+
'Human Duplicate', 'Human Duplicate']),
94+
('@_Human', 0, ['Human Myself', 'Human 1', 'Human 2',
95+
'Human Duplicate', 'Human Duplicate']),
9296
('@_*Human', None, []), # NOTE: Optional single star fails
93-
('@_**Human', 0, ['Human Myself', 'Human 1', 'Human 2']),
94-
('@Human', None, ['Human Myself', 'Human 1', 'Human 2']),
97+
('@_**Human', 0, ['Human Myself', 'Human 1', 'Human 2',
98+
'Human Duplicate', 'Human Duplicate']),
99+
('@Human', None, ['Human Myself', 'Human 1', 'Human 2',
100+
'Human Duplicate', 'Human Duplicate']),
95101
('@NoMatch', None, []),
96102
# streams
97103
('#Stream', 0, ['Stream 1', 'Stream 2', 'Secret stream',
@@ -122,13 +128,19 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
122128
('@Human', 0, '@**Human Myself**'),
123129
('@Human', 1, '@**Human 1**'),
124130
('@Human', 2, '@**Human 2**'),
125-
('@Human', -1, '@**Human 2**'),
126-
('@Human', -2, '@**Human 1**'),
127-
('@Human', -3, '@**Human Myself**'),
128-
('@Human', -4, None),
131+
('@Human', 3, '@**Human Duplicate**'),
132+
('@Human', 4, '@**Human Duplicate**'),
133+
('@Human', -1, '@**Human Duplicate**'),
134+
('@Human', -2, '@**Human Duplicate**'),
135+
('@Human', -3, '@**Human 2**'),
136+
('@Human', -4, '@**Human 1**'),
137+
('@Human', -5, '@**Human Myself**'),
138+
('@Human', -6, None),
129139
('@_Human', 0, '@_**Human Myself**'),
130140
('@_Human', 1, '@_**Human 1**'),
131141
('@_Human', 2, '@_**Human 2**'),
142+
('@_Human', 3, '@_**Human Duplicate**'),
143+
('@_Human', 4, '@_**Human Duplicate**'),
132144
('@H', 1, '@**Human 1**'),
133145
('@Hu', 1, '@**Human 1**'),
134146
('@Hum', 1, '@**Human 1**'),
@@ -155,18 +167,22 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
155167
('@', 0, '@**Human Myself**'),
156168
('@', 1, '@**Human 1**'),
157169
('@', 2, '@**Human 2**'),
158-
('@', 3, '@*Group 1*'),
159-
('@', 4, '@*Group 2*'),
160-
('@', 5, '@*Group 3*'),
161-
('@', 6, '@*Group 4*'),
162-
('@', 7, None), # Reached last match
163-
('@', 8, None), # Beyond end
170+
('@', 3, '@**Human Duplicate**'),
171+
('@', 4, '@**Human Duplicate**'),
172+
('@', 5, '@*Group 1*'),
173+
('@', 6, '@*Group 2*'),
174+
('@', 7, '@*Group 3*'),
175+
('@', 8, '@*Group 4*'),
176+
('@', 9, None), # Reached last match
177+
('@', 10, None), # Beyond end
164178
# Expected sequence of autocompletes from '@**' (no groups)
165179
('@**', 0, '@**Human Myself**'),
166180
('@**', 1, '@**Human 1**'),
167181
('@**', 2, '@**Human 2**'),
168-
('@**', 3, None), # Reached last match
169-
('@**', 4, None), # Beyond end
182+
('@', 3, '@**Human Duplicate**'),
183+
('@', 4, '@**Human Duplicate**'),
184+
('@**', 5, None), # Reached last match
185+
('@**', 6, None), # Beyond end
170186
# Expected sequence of autocompletes from '@*' (only groups)
171187
('@*', 0, '@*Group 1*'),
172188
('@*', 1, '@*Group 2*'),
@@ -178,9 +194,11 @@ def test_generic_autocomplete_set_footer(self, mocker, write_box,
178194
('@_', 0, '@_**Human Myself**'), # NOTE: No silent group mention
179195
('@_', 1, '@_**Human 1**'),
180196
('@_', 2, '@_**Human 2**'),
181-
('@_', 3, None), # Reached last match
182-
('@_', 4, None), # Beyond end
183-
('@_', -1, '@_**Human 2**'),
197+
('@_', 3, '@_**Human Duplicate**'),
198+
('@_', 4, '@_**Human Duplicate**'),
199+
('@_', 5, None), # Reached last match
200+
('@_', 6, None), # Beyond end
201+
('@_', -1, '@_**Human Duplicate**'),
184202
# Complex autocomplete prefixes.
185203
('(@H', 0, '(@**Human Myself**'),
186204
('(@H', 1, '(@**Human 1**'),
@@ -319,11 +337,15 @@ def test_generic_autocomplete_emojis(self, write_box, text,
319337
('', [
320338
'Human Myself',
321339
'Human 1',
322-
'Human 2'
340+
'Human 2',
341+
'Human Duplicate',
342+
'Human Duplicate',
323343
], [
324344
'Human Myself <[email protected]>',
325345
'Human 1 <[email protected]>',
326-
'Human 2 <[email protected]>'
346+
'Human 2 <[email protected]>',
347+
'Human Duplicate <[email protected]>',
348+
'Human Duplicate <[email protected]>',
327349
]),
328350
('My', ['Human Myself'],
329351
['Human Myself <[email protected]>']),
@@ -365,14 +387,20 @@ def test__to_box_autocomplete_with_spaces(self, write_box, text,
365387
('Welcome Bot <[email protected]>, Human', [
366388
'Human Myself',
367389
'Human 1',
368-
'Human 2'
390+
'Human 2',
391+
'Human Duplicate',
392+
'Human Duplicate',
369393
], [
370394
'Welcome Bot <[email protected]>, '
371395
'Human Myself <[email protected]>',
372396
'Welcome Bot <[email protected]>, '
373397
'Human 1 <[email protected]>',
374398
'Welcome Bot <[email protected]>, '
375-
'Human 2 <[email protected]>'
399+
'Human 2 <[email protected]>',
400+
'Welcome Bot <[email protected]>, '
401+
'Human Duplicate <[email protected]>',
402+
'Welcome Bot <[email protected]>, '
403+
'Human Duplicate <[email protected]>',
376404
]),
377405
('Welcome Bot <[email protected]>, Notification Bot '
378406
'<[email protected]>, person2',
@@ -382,14 +410,20 @@ def test__to_box_autocomplete_with_spaces(self, write_box, text,
382410
('Email Gateway <[email protected]>,Human', [
383411
'Human Myself',
384412
'Human 1',
385-
'Human 2'
413+
'Human 2',
414+
'Human Duplicate',
415+
'Human Duplicate',
386416
], [
387417
'Email Gateway <[email protected]>, '
388418
'Human Myself <[email protected]>',
389419
'Email Gateway <[email protected]>, '
390420
'Human 1 <[email protected]>',
391421
'Email Gateway <[email protected]>, '
392-
'Human 2 <[email protected]>'
422+
'Human 2 <[email protected]>',
423+
'Email Gateway <[email protected]>, '
424+
'Human Duplicate <[email protected]>',
425+
'Email Gateway <[email protected]>, '
426+
'Human Duplicate <[email protected]>',
393427
]),
394428
('Human 1 <[email protected]>, Notification Bot '
395429
'<[email protected]>,person2',

0 commit comments

Comments
 (0)