1
# Copyright (C) 2009 Google Inc. All rights reserved.
3
# Redistribution and use in source and binary forms, with or without
4
# modification, are permitted provided that the following conditions are
7
# * Redistributions of source code must retain the above copyright
8
# notice, this list of conditions and the following disclaimer.
9
# * Redistributions in binary form must reproduce the above
10
# copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the
12
# * Neither the name of Google Inc. nor the names of its
13
# contributors may be used to endorse or promote products derived from
14
# this software without specific prior written permission.
16
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
from webkitpy.common.config.committers import Account, CommitterList, Contributor, Committer, Reviewer
31
class CommittersTest(unittest.TestCase):
32
def test_committer_lookup(self):
33
account = Account('Test Zero', ['zero@test.com', 'zero@gmail.com'], 'zero')
34
committer = Committer('Test One', 'one@test.com', 'one')
35
reviewer = Reviewer('Test Two', ['two@test.com', 'Two@rad.com', 'so_two@gmail.com'])
36
contributor = Contributor('Test Three', ['Three@test.com'], 'three')
37
contributor_with_two_nicknames = Contributor('Other Four', ['otherfour@webkit.org', 'otherfour@webkit2.org'], ['four', 'otherfour'])
38
contributor_with_same_email_username = Contributor('Yet Another Four', ['otherfour@webkit.com'], ['yetanotherfour'])
39
committer_list = CommitterList(watchers=[account], committers=[committer], reviewers=[reviewer],
40
contributors=[contributor, contributor_with_two_nicknames, contributor_with_same_email_username])
42
# Test valid committer, reviewer and contributor lookup
43
self.assertEqual(committer_list.account_by_email('zero@test.com'), account)
44
self.assertEqual(committer_list.committer_by_email('one@test.com'), committer)
45
self.assertEqual(committer_list.reviewer_by_email('two@test.com'), reviewer)
46
self.assertEqual(committer_list.committer_by_email('two@test.com'), reviewer)
47
self.assertEqual(committer_list.committer_by_email('two@rad.com'), reviewer)
48
self.assertEqual(committer_list.reviewer_by_email('so_two@gmail.com'), reviewer)
49
self.assertEqual(committer_list.contributor_by_email('three@test.com'), contributor)
51
# Test valid committer, reviewer and contributor lookup
52
self.assertEqual(committer_list.committer_by_name("Test One"), committer)
53
self.assertEqual(committer_list.committer_by_name("Test Two"), reviewer)
54
self.assertEqual(committer_list.committer_by_name("Test Three"), None)
55
self.assertEqual(committer_list.contributor_by_name("Test Three"), contributor)
56
self.assertEqual(committer_list.contributor_by_name("test one"), committer)
57
self.assertEqual(committer_list.contributor_by_name("test two"), reviewer)
58
self.assertEqual(committer_list.contributor_by_name("test three"), contributor)
60
# Test that the first email is assumed to be the Bugzilla email address (for now)
61
self.assertEqual(committer_list.committer_by_email('two@rad.com').bugzilla_email(), 'two@test.com')
63
# Test lookup by login email address
64
self.assertEqual(committer_list.account_by_login('zero@test.com'), account)
65
self.assertEqual(committer_list.account_by_login('zero@gmail.com'), None)
66
self.assertEqual(committer_list.account_by_login('one@test.com'), committer)
67
self.assertEqual(committer_list.account_by_login('two@test.com'), reviewer)
68
self.assertEqual(committer_list.account_by_login('Two@rad.com'), None)
69
self.assertEqual(committer_list.account_by_login('so_two@gmail.com'), None)
71
# Test that a known committer is not returned during reviewer lookup
72
self.assertEqual(committer_list.reviewer_by_email('one@test.com'), None)
73
self.assertEqual(committer_list.reviewer_by_email('three@test.com'), None)
74
# and likewise that a known contributor is not returned for committer lookup.
75
self.assertEqual(committer_list.committer_by_email('three@test.com'), None)
77
# Test that unknown email address fail both committer and reviewer lookup
78
self.assertEqual(committer_list.committer_by_email('bar@bar.com'), None)
79
self.assertEqual(committer_list.reviewer_by_email('bar@bar.com'), None)
81
# Test that emails returns a list.
82
self.assertEqual(committer.emails, ['one@test.com'])
84
self.assertEqual(committer.irc_nicknames, ['one'])
85
self.assertEqual(committer_list.contributor_by_irc_nickname('one'), committer)
86
self.assertEqual(committer_list.contributor_by_irc_nickname('three'), contributor)
87
self.assertEqual(committer_list.contributor_by_irc_nickname('four'), contributor_with_two_nicknames)
88
self.assertEqual(committer_list.contributor_by_irc_nickname('otherfour'), contributor_with_two_nicknames)
90
# Test that the lists returned are are we expect them.
91
self.assertEqual(committer_list.contributors(), [contributor, contributor_with_two_nicknames, contributor_with_same_email_username, committer, reviewer])
92
self.assertEqual(committer_list.committers(), [committer, reviewer])
93
self.assertEqual(committer_list.reviewers(), [reviewer])
95
self.assertEqual(committer_list.contributors_by_search_string('test'), [contributor, committer, reviewer])
96
self.assertEqual(committer_list.contributors_by_search_string('rad'), [reviewer])
97
self.assertEqual(committer_list.contributors_by_search_string('Two'), [reviewer])
99
self.assertEqual(committer_list.contributors_by_email_username("one"), [committer])
100
self.assertEqual(committer_list.contributors_by_email_username("four"), [])
101
self.assertEqual(committer_list.contributors_by_email_username("otherfour"), [contributor_with_two_nicknames, contributor_with_same_email_username])
103
def _assert_fuzz_match(self, text, name_of_expected_contributor, expected_distance):
104
committers = CommitterList()
105
contributors, distance = committers.contributors_by_fuzzy_match(text)
106
if type(name_of_expected_contributor) is list:
107
expected_names = name_of_expected_contributor
109
expected_names = [name_of_expected_contributor] if name_of_expected_contributor else []
110
self.assertEqual(([contributor.full_name for contributor in contributors], distance), (expected_names, expected_distance))
112
# Basic testing of the edit distance matching ...
113
def test_contributors_by_fuzzy_match(self):
114
self._assert_fuzz_match('Geoff Garen', 'Geoffrey Garen', 3)
115
self._assert_fuzz_match('Kenneth Christiansen', 'Kenneth Rohde Christiansen', 6)
116
self._assert_fuzz_match('Sam', 'Sam Weinig', 0)
117
self._assert_fuzz_match('me', None, 2)
119
# The remaining tests test that certain names are resolved in a specific way.
120
# We break this up into multiple tests so that each is faster and they can
121
# be run in parallel. Unfortunately each test scans the entire committers list,
122
# so these are inherently slow (see https://bugs.webkit.org/show_bug.cgi?id=79179).
124
# Commented out lines are test cases imported from the bug 26533 yet to pass.
126
def integration_test_contributors__none(self):
127
self._assert_fuzz_match('myself', None, 6)
128
self._assert_fuzz_match('others', None, 6)
129
self._assert_fuzz_match('BUILD FIX', None, 9)
131
def integration_test_contributors__none_2(self):
132
self._assert_fuzz_match('but Dan Bernstein also reviewed', None, 31)
133
self._assert_fuzz_match('asked thoughtful questions', None, 26)
134
self._assert_fuzz_match('build fix of mac', None, 16)
136
def integration_test_contributors__none_3(self):
137
self._assert_fuzz_match('a spell checker', None, 15)
138
self._assert_fuzz_match('nobody, build fix', None, 17)
139
self._assert_fuzz_match('NOBODY (chromium build fix)', None, 27)
141
def integration_test_contributors_ada_chan(self):
142
self._assert_fuzz_match('Ada', 'Ada Chan', 0)
144
def integration_test_contributors_adele_peterson(self):
145
self._assert_fuzz_match('adele', 'Adele Peterson', 0)
147
def integration_test_contributors_adele_peterson(self):
148
# self._assert_fuzz_match('Adam', 'Adam Roben', 0)
149
self._assert_fuzz_match('aroben', 'Adam Roben', 0)
151
def integration_test_contributors_alexey_proskuryakov(self):
152
# self._assert_fuzz_match('Alexey', 'Alexey Proskuryakov', 0)
153
self._assert_fuzz_match('ap', 'Alexey Proskuryakov', 0)
154
self._assert_fuzz_match('Alexey P', 'Alexey Proskuryakov', 0)
156
def integration_test_contributors_alice_liu(self):
157
# self._assert_fuzz_match('Alice', 'Alice Liu', 0)
158
self._assert_fuzz_match('aliu', 'Alice Liu', 0)
159
self._assert_fuzz_match('Liu', 'Alice Liu', 0)
161
def integration_test_contributors_alp_toker(self):
162
self._assert_fuzz_match('Alp', 'Alp Toker', 0)
164
def integration_test_contributors_anders_carlsson(self):
165
self._assert_fuzz_match('Anders', 'Anders Carlsson', 0)
166
self._assert_fuzz_match('andersca', 'Anders Carlsson', 0)
167
self._assert_fuzz_match('anders', 'Anders Carlsson', 0)
168
self._assert_fuzz_match('Andersca', 'Anders Carlsson', 0)
170
def integration_test_contributors_antti_koivisto(self):
171
self._assert_fuzz_match('Antti "printf" Koivisto', 'Antti Koivisto', 9)
172
self._assert_fuzz_match('Antti', 'Antti Koivisto', 0)
174
def integration_test_contributors_beth_dakin(self):
175
self._assert_fuzz_match('Beth', 'Beth Dakin', 0)
176
self._assert_fuzz_match('beth', 'Beth Dakin', 0)
177
self._assert_fuzz_match('bdakin', 'Beth Dakin', 0)
179
def integration_test_contributors_brady_eidson(self):
180
self._assert_fuzz_match('Brady', 'Brady Eidson', 0)
181
self._assert_fuzz_match('bradee-oh', 'Brady Eidson', 0)
182
self._assert_fuzz_match('Brady', 'Brady Eidson', 0)
184
def integration_test_contributors_cameron_zwarich(self):
185
pass # self._assert_fuzz_match('Cameron', 'Cameron Zwarich', 0)
186
# self._assert_fuzz_match('cpst', 'Cameron Zwarich', 1)
188
def integration_test_contributors_chris_blumenberg(self):
189
# self._assert_fuzz_match('Chris', 'Chris Blumenberg', 0)
190
self._assert_fuzz_match('cblu', 'Chris Blumenberg', 0)
192
def integration_test_contributors_dan_bernstein(self):
193
self._assert_fuzz_match('Dan', ['Dan Winship', 'Dan Bernstein'], 0)
194
self._assert_fuzz_match('Dan B', 'Dan Bernstein', 0)
195
# self._assert_fuzz_match('mitz', 'Dan Bernstein', 0)
196
self._assert_fuzz_match('Mitz Pettel', 'Dan Bernstein', 1)
197
self._assert_fuzz_match('Mitzpettel', 'Dan Bernstein', 0)
198
self._assert_fuzz_match('Mitz Pettel RTL', 'Dan Bernstein', 5)
200
def integration_test_contributors_dan_bernstein_2(self):
201
self._assert_fuzz_match('Teh Mitzpettel', 'Dan Bernstein', 4)
202
# self._assert_fuzz_match('The Mitz', 'Dan Bernstein', 0)
203
self._assert_fuzz_match('Dr Dan Bernstein', 'Dan Bernstein', 3)
205
def integration_test_contributors_darin_adler(self):
206
self._assert_fuzz_match('Darin Adler\'', 'Darin Adler', 1)
207
self._assert_fuzz_match('Darin', 'Darin Adler', 0) # Thankfully "Fisher" is longer than "Adler"
208
self._assert_fuzz_match('darin', 'Darin Adler', 0)
210
def integration_test_contributors_david_harrison(self):
211
self._assert_fuzz_match('Dave Harrison', 'David Harrison', 2)
212
self._assert_fuzz_match('harrison', 'David Harrison', 0)
213
self._assert_fuzz_match('Dr. Harrison', 'David Harrison', 4)
215
def integration_test_contributors_david_harrison_2(self):
216
self._assert_fuzz_match('Dave Harrson', 'David Harrison', 3)
217
self._assert_fuzz_match('Dave Harrsion', 'David Harrison', 4) # Damerau-Levenshtein distance is 3
219
def integration_test_contributors_david_hyatt(self):
220
self._assert_fuzz_match('Dave Hyatt', 'David Hyatt', 2)
221
self._assert_fuzz_match('Daddy Hyatt', 'David Hyatt', 3)
222
# self._assert_fuzz_match('Dave', 'David Hyatt', 0) # 'Dave' could mean harrison.
223
self._assert_fuzz_match('hyatt', 'David Hyatt', 0)
224
# self._assert_fuzz_match('Haytt', 'David Hyatt', 0) # Works if we had implemented Damerau-Levenshtein distance!
226
def integration_test_contributors_david_kilzer(self):
227
self._assert_fuzz_match('Dave Kilzer', 'David Kilzer', 2)
228
self._assert_fuzz_match('David D. Kilzer', 'David Kilzer', 3)
229
self._assert_fuzz_match('ddkilzer', 'David Kilzer', 0)
231
def integration_test_contributors_don_melton(self):
232
self._assert_fuzz_match('Don', 'Don Melton', 0)
233
self._assert_fuzz_match('Gramps', 'Don Melton', 0)
235
def integration_test_contributors_eric_seidel(self):
236
# self._assert_fuzz_match('eric', 'Eric Seidel', 0)
237
self._assert_fuzz_match('Eric S', 'Eric Seidel', 0)
238
# self._assert_fuzz_match('MacDome', 'Eric Seidel', 0)
239
self._assert_fuzz_match('eseidel', 'Eric Seidel', 0)
241
def integration_test_contributors_geoffrey_garen(self):
242
# self._assert_fuzz_match('Geof', 'Geoffrey Garen', 4)
243
# self._assert_fuzz_match('Geoff', 'Geoffrey Garen', 3)
244
self._assert_fuzz_match('Geoff Garen', 'Geoffrey Garen', 3)
245
self._assert_fuzz_match('ggaren', 'Geoffrey Garen', 0)
246
# self._assert_fuzz_match('geoff', 'Geoffrey Garen', 0)
247
self._assert_fuzz_match('Geoffrey', 'Geoffrey Garen', 0)
248
self._assert_fuzz_match('GGaren', 'Geoffrey Garen', 0)
250
def integration_test_contributors_greg_bolsinga(self):
251
pass # self._assert_fuzz_match('Greg', 'Greg Bolsinga', 0)
253
def integration_test_contributors_holger_freyther(self):
254
self._assert_fuzz_match('Holger', 'Holger Freyther', 0)
255
self._assert_fuzz_match('Holger Hans Peter Freyther', 'Holger Freyther', 11)
257
def integration_test_contributors_jon_sullivan(self):
258
# self._assert_fuzz_match('john', 'John Sullivan', 0)
259
self._assert_fuzz_match('sullivan', 'John Sullivan', 0)
261
def integration_test_contributors_jon_honeycutt(self):
262
self._assert_fuzz_match('John Honeycutt', 'Jon Honeycutt', 1)
263
# self._assert_fuzz_match('Jon', 'Jon Honeycutt', 0)
265
def integration_test_contributors_jon_honeycutt(self):
266
# self._assert_fuzz_match('justin', 'Justin Garcia', 0)
267
self._assert_fuzz_match('justing', 'Justin Garcia', 0)
269
def integration_test_contributors_joseph_pecoraro(self):
270
self._assert_fuzz_match('Joe Pecoraro', 'Joseph Pecoraro', 3)
272
def integration_test_contributors_ken_kocienda(self):
273
self._assert_fuzz_match('ken', 'Ken Kocienda', 0)
274
self._assert_fuzz_match('kocienda', 'Ken Kocienda', 0)
276
def integration_test_contributors_kenneth_russell(self):
277
self._assert_fuzz_match('Ken Russell', 'Kenneth Russell', 4)
279
def integration_test_contributors_kevin_decker(self):
280
self._assert_fuzz_match('kdecker', 'Kevin Decker', 0)
282
def integration_test_contributors_kevin_mccullough(self):
283
self._assert_fuzz_match('Kevin M', 'Kevin McCullough', 0)
284
self._assert_fuzz_match('Kevin McCulough', 'Kevin McCullough', 1)
285
self._assert_fuzz_match('mccullough', 'Kevin McCullough', 0)
287
def integration_test_contributors_lars_knoll(self):
288
self._assert_fuzz_match('lars', 'Lars Knoll', 0)
290
def integration_test_contributors_lars_weintraub(self):
291
self._assert_fuzz_match('levi', 'Levi Weintraub', 0)
293
def integration_test_contributors_maciej_stachowiak(self):
294
self._assert_fuzz_match('Maciej', 'Maciej Stachowiak', 0)
295
# self._assert_fuzz_match('mjs', 'Maciej Stachowiak', 0)
296
self._assert_fuzz_match('Maciej S', 'Maciej Stachowiak', 0)
298
def integration_test_contributors_mark_rowe(self):
299
# self._assert_fuzz_match('Mark', 'Mark Rowe', 0)
300
self._assert_fuzz_match('bdash', 'Mark Rowe', 0)
301
self._assert_fuzz_match('mrowe', 'Mark Rowe', 0)
302
# self._assert_fuzz_match('Brian Dash', 'Mark Rowe', 0)
304
def integration_test_contributors_nikolas_zimmermann(self):
305
# self._assert_fuzz_match('Niko', 'Nikolas Zimmermann', 1)
306
self._assert_fuzz_match('Niko Zimmermann', 'Nikolas Zimmermann', 3)
307
self._assert_fuzz_match('Nikolas', 'Nikolas Zimmermann', 0)
309
def integration_test_contributors_oliver_hunt(self):
310
# self._assert_fuzz_match('Oliver', 'Oliver Hunt', 0)
311
self._assert_fuzz_match('Ollie', 'Oliver Hunt', 1)
312
self._assert_fuzz_match('Olliej', 'Oliver Hunt', 0)
313
self._assert_fuzz_match('Olliej Hunt', 'Oliver Hunt', 3)
314
self._assert_fuzz_match('olliej', 'Oliver Hunt', 0)
315
self._assert_fuzz_match('ollie', 'Oliver Hunt', 1)
316
self._assert_fuzz_match('ollliej', 'Oliver Hunt', 1)
318
def integration_test_contributors_oliver_hunt(self):
319
self._assert_fuzz_match('Richard', 'Richard Williamson', 0)
320
self._assert_fuzz_match('rjw', 'Richard Williamson', 0)
322
def integration_test_contributors_oliver_hunt(self):
323
self._assert_fuzz_match('Rob', 'Rob Buis', 0)
324
self._assert_fuzz_match('rwlbuis', 'Rob Buis', 0)
326
def integration_test_contributors_rniwa(self):
327
self._assert_fuzz_match('rniwa@webkit.org', 'Ryosuke Niwa', 0)
329
def disabled_integration_test_contributors_simon_fraser(self):
330
pass # self._assert_fuzz_match('Simon', 'Simon Fraser', 0)
332
def integration_test_contributors_steve_falkenburg(self):
333
self._assert_fuzz_match('Sfalken', 'Steve Falkenburg', 0)
334
# self._assert_fuzz_match('Steve', 'Steve Falkenburg', 0)
336
def integration_test_contributors_sam_weinig(self):
337
self._assert_fuzz_match('Sam', 'Sam Weinig', 0)
338
# self._assert_fuzz_match('Weinig Sam', 'weinig', 0)
339
self._assert_fuzz_match('Weinig', 'Sam Weinig', 0)
340
self._assert_fuzz_match('Sam W', 'Sam Weinig', 0)
341
self._assert_fuzz_match('Sammy Weinig', 'Sam Weinig', 2)
343
def integration_test_contributors_tim_omernick(self):
344
# self._assert_fuzz_match('timo', 'Tim Omernick', 0)
345
self._assert_fuzz_match('TimO', 'Tim Omernick', 0)
346
# self._assert_fuzz_match('Timo O', 'Tim Omernick', 0)
347
# self._assert_fuzz_match('Tim O.', 'Tim Omernick', 0)
348
self._assert_fuzz_match('Tim O', 'Tim Omernick', 0)
350
def integration_test_contributors_timothy_hatcher(self):
351
# self._assert_fuzz_match('Tim', 'Timothy Hatcher', 0)
352
# self._assert_fuzz_match('Tim H', 'Timothy Hatcher', 0)
353
self._assert_fuzz_match('Tim Hatcher', 'Timothy Hatcher', 4)
354
self._assert_fuzz_match('Tim Hatcheri', 'Timothy Hatcher', 5)
355
self._assert_fuzz_match('timothy', 'Timothy Hatcher', 0)
356
self._assert_fuzz_match('thatcher', 'Timothy Hatcher', 1)
357
self._assert_fuzz_match('xenon', 'Timothy Hatcher', 0)
358
self._assert_fuzz_match('Hatcher', 'Timothy Hatcher', 0)
359
# self._assert_fuzz_match('TimH', 'Timothy Hatcher', 0)
361
def integration_test_contributors_tor_arne_vestbo(self):
362
self._assert_fuzz_match('Tor Arne', u"Tor Arne Vestb\u00f8", 1) # Matches IRC nickname
364
def integration_test_contributors_vicki_murley(self):
365
self._assert_fuzz_match('Vicki', u"Vicki Murley", 0)
367
def integration_test_contributors_zack_rusin(self):
368
self._assert_fuzz_match('Zack', 'Zack Rusin', 0)