Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit 8d969fd

Browse files
authored
Merge pull request #252 from rust-lang/rip-irc
Remove IRC support
2 parents 5a2e88f + 7f1cbd2 commit 8d969fd

File tree

5 files changed

+0
-187
lines changed

5 files changed

+0
-187
lines changed

highfive/irc.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

highfive/newpr.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from copy import deepcopy
1111
from io import StringIO
1212

13-
from highfive import irc
14-
1513
# Maximum per page is 100. Sorted by number of commits, so most of the time the
1614
# contributor will happen early,
1715
post_comment_url = "https://api.github.com/repos/%s/%s/issues/%s/comments"
@@ -117,12 +115,6 @@ def set_assignee(self, assignee, owner, repo, issue, user, author, to_mention):
117115
else:
118116
raise e
119117

120-
if assignee:
121-
irc_name_of_reviewer = self.get_irc_nick(assignee)
122-
if irc_name_of_reviewer:
123-
client = irc.IrcClient(target="#rust-bots")
124-
client.send_then_quit("{}: ping to review issue https://www.github.com/{}/{}/pull/{} by {}."
125-
.format(irc_name_of_reviewer, owner, repo, issue, author))
126118
self.run_commands(to_mention, owner, repo, issue, user)
127119

128120
def run_commands(self, to_mention, owner, repo, issue, user):
@@ -148,22 +140,6 @@ def run_commands(self, to_mention, owner, repo, issue, user):
148140
if len(message) > 0:
149141
self.post_comment(message, owner, repo, issue)
150142

151-
def get_irc_nick(self, gh_name):
152-
""" returns None if the request status code is not 200,
153-
if the user does not exist on the rustacean database,
154-
or if the user has no `irc` field associated with their username
155-
"""
156-
try:
157-
data = urllib.request.urlopen(rustaceans_api_url.format(username=gh_name))
158-
if data.getcode() == 200:
159-
rustacean_data = json.loads(data.read())
160-
if rustacean_data:
161-
return rustacean_data[0].get("irc")
162-
except urllib.error.HTTPError:
163-
pass
164-
165-
return None
166-
167143
def is_collaborator(self, commenter, owner, repo):
168144
"""Returns True if `commenter` is a collaborator in the repo."""
169145
try:

highfive/tests/test_integration_tests.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,10 @@ class TestNewPr(object):
6262
@pytest.fixture(autouse=True)
6363
def make_mocks(cls, patcherize):
6464
cls.mocks = patcherize((
65-
('get_irc_nick', 'highfive.newpr.HighfiveHandler.get_irc_nick'),
6665
('ConfigParser', 'highfive.newpr.ConfigParser'),
6766
('load_json_file', 'highfive.newpr.HighfiveHandler._load_json_file'),
6867
))
6968

70-
cls.mocks['get_irc_nick'].return_value = None
71-
7269
cls.mocks['load_json_file'].side_effect = (
7370
fakes.get_repo_configs()['individuals_no_dirs'],
7471
fakes.get_global_configs()['base'],
@@ -255,12 +252,9 @@ class TestNewComment(object):
255252
@pytest.fixture(autouse=True)
256253
def make_mocks(cls, patcherize):
257254
cls.mocks = patcherize((
258-
('get_irc_nick', 'highfive.newpr.HighfiveHandler.get_irc_nick'),
259255
('ConfigParser', 'highfive.newpr.ConfigParser'),
260256
))
261257

262-
cls.mocks['get_irc_nick'].return_value = None
263-
264258
config_mock = mock.Mock()
265259
config_mock.get.side_effect = ('integration-user', 'integration-token')
266260
cls.mocks['ConfigParser'].RawConfigParser.return_value = config_mock

highfive/tests/test_irc.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

highfive/tests/test_newpr.py

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -346,57 +346,6 @@ def test_find_reviewer(self):
346346
assert handler.find_reviewer(msg) is None, \
347347
"expected '%s' to have no reviewer extracted" % msg
348348

349-
def setup_get_irc_nick_mocks(self, mock_urllib, status_code, data=None):
350-
if status_code != 200:
351-
mock_urllib.side_effect = HTTPError(
352-
None, status_code, None, None, None
353-
)
354-
return
355-
356-
mock_data = mock.Mock()
357-
mock_data.getcode.return_value = status_code
358-
mock_data.read.return_value = data
359-
mock_urllib.request.urlopen.return_value = mock_data
360-
return mock_data
361-
362-
@mock.patch('highfive.newpr.urllib')
363-
def test_get_irc_nick_non_200(self, mock_urllib):
364-
handler = HighfiveHandlerMock(Payload({})).handler
365-
self.setup_get_irc_nick_mocks(mock_urllib, 503)
366-
assert handler.get_irc_nick('foo') is None
367-
368-
mock_urllib.request.urlopen.assert_called_with(
369-
'http://www.ncameron.org/rustaceans/user?username=foo'
370-
)
371-
372-
@mock.patch('highfive.newpr.urllib')
373-
def test_get_irc_nick_no_data(self, mock_urllib):
374-
handler = HighfiveHandlerMock(Payload({})).handler
375-
mock_data = self.setup_get_irc_nick_mocks(mock_urllib, 200, '[]')
376-
assert handler.get_irc_nick('foo') is None
377-
378-
mock_urllib.request.urlopen.assert_called_with(
379-
'http://www.ncameron.org/rustaceans/user?username=foo'
380-
)
381-
mock_data.getcode.assert_called()
382-
mock_data.read.assert_called()
383-
384-
@mock.patch('highfive.newpr.urllib')
385-
def test_get_irc_nick_has_data(self, mock_urllib):
386-
handler = HighfiveHandlerMock(Payload({})).handler
387-
mock_data = self.setup_get_irc_nick_mocks(
388-
mock_urllib, 200,
389-
'[{"username":"nrc","name":"Nick Cameron","irc":"nrc","email":"[email protected]","discourse":"nrc","reddit":"nick29581","twitter":"@nick_r_cameron","blog":"https://www.ncameron.org/blog","website":"https://www.ncameron.org","notes":"<p>I work on the Rust compiler, language design, and tooling. I lead the dev tools team and am part of the core team. I&#39;m part of the research team at Mozilla.</p>\\n","avatar":"https://avatars.githubusercontent.com/nrc","irc_channels":["rust-dev-tools","rust","rust-internals","rust-lang","rustc","servo"]}]'
390-
)
391-
assert handler.get_irc_nick('nrc') == 'nrc'
392-
393-
mock_urllib.request.urlopen.assert_called_with(
394-
'http://www.ncameron.org/rustaceans/user?username=nrc'
395-
)
396-
mock_data.getcode.assert_called()
397-
mock_data.read.assert_called()
398-
399-
400349
class TestApiReq(TestNewPR):
401350
@pytest.fixture(autouse=True)
402351
def make_defaults(cls, patcherize):
@@ -537,13 +486,9 @@ class TestSetAssignee(TestNewPR):
537486
def make_defaults(cls, patcherize):
538487
cls.mocks = patcherize((
539488
('api_req', 'highfive.newpr.HighfiveHandler.api_req'),
540-
('get_irc_nick', 'highfive.newpr.HighfiveHandler.get_irc_nick'),
541489
('post_comment', 'highfive.newpr.HighfiveHandler.post_comment'),
542-
('IrcClient', 'highfive.irc.IrcClient'),
543490
))
544491

545-
cls.mocks['client'] = cls.mocks['IrcClient'].return_value
546-
547492
cls.handler = HighfiveHandlerMock(Payload({})).handler
548493
cls.assignee = 'assigneeUser'
549494
cls.author = 'authorUser'
@@ -570,24 +515,16 @@ def assert_api_req_call(self, assignee=''):
570515
)
571516

572517
def test_api_req_good(self):
573-
self.mocks['get_irc_nick'].return_value = None
574518
self.set_assignee()
575519

576520
self.assert_api_req_call()
577-
self.mocks['get_irc_nick'].assert_called_once_with(self.assignee)
578-
self.mocks['IrcClient'].assert_not_called()
579-
self.mocks['client'].send_then_quit.assert_not_called()
580521
self.mocks['post_comment'].assert_not_called()
581522

582523
def test_api_req_201(self):
583524
self.mocks['api_req'].side_effect = HTTPError(None, 201, None, None, None)
584-
self.mocks['get_irc_nick'].return_value = None
585525
self.set_assignee()
586526

587527
self.assert_api_req_call()
588-
self.mocks['get_irc_nick'].assert_called_once_with(self.assignee)
589-
self.mocks['IrcClient'].assert_not_called()
590-
self.mocks['client'].send_then_quit.assert_not_called()
591528
self.mocks['post_comment'].assert_not_called()
592529

593530
def test_api_req_error(self):
@@ -596,30 +533,15 @@ def test_api_req_error(self):
596533
self.set_assignee()
597534

598535
self.assert_api_req_call()
599-
self.mocks['get_irc_nick'].assert_not_called()
600-
self.mocks['IrcClient'].assert_not_called()
601-
self.mocks['client'].send_then_quit.assert_not_called()
602536
self.mocks['post_comment'].assert_not_called()
603537

604538
def test_has_nick(self):
605-
irc_nick = 'nick'
606-
self.mocks['get_irc_nick'].return_value = irc_nick
607-
608539
self.set_assignee()
609540

610541
self.assert_api_req_call()
611-
self.mocks['get_irc_nick'].assert_called_once_with(self.assignee)
612-
self.mocks['IrcClient'].assert_called_once_with(target='#rust-bots')
613-
self.mocks['client'].send_then_quit.assert_called_once_with(
614-
"{}: ping to review issue https://www.github.com/{}/{}/pull/{} by {}.".format(
615-
irc_nick, self.owner, self.repo, self.issue, self.author
616-
)
617-
)
618542
self.mocks['post_comment'].assert_not_called()
619543

620544
def test_has_to_mention(self):
621-
self.mocks['get_irc_nick'].return_value = None
622-
623545
to_mention = [
624546
{
625547
'message': 'This is important',
@@ -633,9 +555,6 @@ def test_has_to_mention(self):
633555
self.set_assignee(to_mention=to_mention)
634556

635557
self.assert_api_req_call()
636-
self.mocks['get_irc_nick'].assert_called_once_with(self.assignee)
637-
self.mocks['IrcClient'].assert_not_called()
638-
self.mocks['client'].send_then_quit.assert_not_called()
639558
self.mocks['post_comment'].assert_called_once_with(
640559
'This is important\n\ncc @userA,@userB,@userC\n\nAlso important\n\ncc @userD',
641560
self.owner, self.repo, self.issue
@@ -645,9 +564,6 @@ def test_no_assignee(self):
645564
self.set_assignee(None)
646565

647566
self.assert_api_req_call(None)
648-
self.mocks['get_irc_nick'].assert_not_called()
649-
self.mocks['IrcClient'].assert_not_called()
650-
self.mocks['client'].send_then_quit.assert_not_called()
651567
self.mocks['post_comment'].assert_not_called()
652568

653569

0 commit comments

Comments
 (0)