Skip to content

Commit

Permalink
LabHub: Use activate instead of init
Browse files Browse the repository at this point in the history
__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 #554
  • Loading branch information
nvzard committed Jul 4, 2018
1 parent de4fbaf commit 492a529
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions plugins/labhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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):
Expand Down
11 changes: 6 additions & 5 deletions tests/labhub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 492a529

Please sign in to comment.