From 492a5298814e2e26ac83cfa96625424d093a5bcd Mon Sep 17 00:00:00 2001 From: Nitanshu Date: Tue, 3 Jul 2018 21:51:56 +0530 Subject: [PATCH] LabHub: Use activate instead of init __init__ is executed at load time and and any issue in the plugin will lead to it not showing up. LifeCycle: __init__->configured->enable Closes https://github.com/coala/corobo/issues/554 --- plugins/labhub.py | 5 ++--- tests/labhub_test.py | 11 ++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/labhub.py b/plugins/labhub.py index cee87e6c..4b1c7146 100644 --- a/plugins/labhub.py +++ b/plugins/labhub.py @@ -20,9 +20,7 @@ class LabHub(BotPlugin): GH_ORG_NAME = constants.GH_ORG_NAME GL_ORG_NAME = constants.GL_ORG_NAME - def __init__(self, bot, name=None): - super().__init__(bot, name) - + def activate(self): teams = dict() try: gh = github3.login(token=os.environ.get('GH_TOKEN')) @@ -62,6 +60,7 @@ def __init__(self, bot, name=None): self.REPOS.update(self.gl_repos) self.hello_world_users = set() + super().activate() @property def TEAMS(self): diff --git a/tests/labhub_test.py b/tests/labhub_test.py index d5732f24..8288972a 100644 --- a/tests/labhub_test.py +++ b/tests/labhub_test.py @@ -114,10 +114,11 @@ def test_hello_world_callback(self): 'coala developers': self.mock_team, 'coala maintainers': self.mock_team, } - - testbot = TestBot(extra_plugin_dir='plugins', loglevel=logging.ERROR) - testbot.start() - labhub = testbot.bot.plugin_manager.get_plugin_obj_by_name('LabHub') + labhub, testbot = plugin_testbot(plugins.labhub.LabHub, logging.ERROR) + labhub.activate() + #testbot = TestBot(extra_plugin_dir='plugins', loglevel=logging.ERROR) + #testbot.start() + #labhub = testbot.bot.plugin_manager.get_plugin_obj_by_name('LabHub') labhub.TEAMS = teams self.mock_team.is_member.return_value = False testbot.assertCommand('hello, world', 'newcomer') @@ -235,7 +236,7 @@ def test_assign_cmd(self): testbot.assertCommand(cmd.format('coala', 'a', '23'), 'You\'ve been assigned to the issue') - + # no assignee, newcomer, initiatives/gci mock_maint_team.is_member.return_value = False mock_dev_team.is_member.return_value = False