Skip to content

Commit

Permalink
requirements.txt: Update Errbot
Browse files Browse the repository at this point in the history
`errbot.plugin_manager.instanciateElement` has
been deprecated. Fix for loading templates is
included.

Closes #571
  • Loading branch information
nvzard committed Jul 11, 2018
1 parent de4fbaf commit f9e7c7e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .moban.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: corobo

dependencies:
- pyopenssl<17.5
- git+https://github.com/errbotio/errbot@c2639879d4c298933cdf406193de5a5e626db12b
- git+https://github.com/errbotio/errbot@a0f35732484c8c0692e123c48653517cffa21a42
- wolframalpha
- github3.py~=1.0.0
- IGitt==0.4.1.dev20180317153318
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyopenssl<17.5
git+https://github.com/errbotio/errbot@c2639879d4c298933cdf406193de5a5e626db12b
git+https://github.com/errbotio/errbot@a0f35732484c8c0692e123c48653517cffa21a42
wolframalpha
github3.py~=1.0.0
IGitt==0.4.1.dev20180317153318
Expand Down
4 changes: 2 additions & 2 deletions tests/ban_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestBan(unittest.TestCase):
@patch('plugins.ban.requests')
@patch('plugins.ban.json')
def test_ban_cmd(self, mockjson, mockreq):
ban, testbot = plugin_testbot(plugins.ban.Ban, logging.ERROR)
ban, testbot = plugin_testbot(plugins.ban.Ban, 'Ban', logging.ERROR)
ban.activate()

ban.bot_config.ROOMS_TO_JOIN = ('coala/coala', 'coala/coala-bears')
Expand All @@ -34,7 +34,7 @@ def test_ban_cmd(self, mockjson, mockreq):
@patch('plugins.ban.requests')
@patch('plugins.ban.json')
def test_unban_cmd(self, mockjson, mockreq):
ban, testbot = plugin_testbot(plugins.ban.Ban, logging.ERROR)
ban, testbot = plugin_testbot(plugins.ban.Ban, 'Ban', logging.ERROR)
ban.activate()

ban.bot_config.ROOMS_TO_JOIN = ('coala/coala', 'coala/coala-bears')
Expand Down
2 changes: 1 addition & 1 deletion tests/git_stats_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):
self.plugin.__bases__ = (BotPlugin, )

def test_pr_list(self):
git_stats, testbot = plugin_testbot(self.plugin, logging.ERROR)
git_stats, testbot = plugin_testbot(self.plugin, 'git_stats', logging.ERROR)
git_stats.activate()

git_stats.REPOS = {'test': self.mock_repo}
Expand Down
4 changes: 2 additions & 2 deletions tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from errbot.backends.test import TestBot

def plugin_testbot(klass, loglevel, config=None):
def plugin_testbot(klass, plugin_name, loglevel, config=None):
config = config if config else dict()
testbot = TestBot(loglevel=loglevel, extra_config=config)
testbot.start()
plug = testbot.bot.plugin_manager.instanciateElement(klass)
plug = klass(testbot.bot, plugin_name)
return plug, testbot
29 changes: 22 additions & 7 deletions tests/labhub_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
from unittest.mock import Mock, MagicMock, create_autospec, PropertyMock, patch

import errbot
import github3
import IGitt
from IGitt.GitHub.GitHubMergeRequest import GitHubMergeRequest
Expand All @@ -13,6 +14,9 @@

from errbot.backends.test import TestBot
from errbot.backends.base import Message
from errbot.plugin_info import PluginInfo
from errbot.templating import add_plugin_templates_path
from pathlib import Path

import plugins.labhub
from plugins.labhub import LabHub
Expand All @@ -22,6 +26,12 @@
class TestLabHub(unittest.TestCase):

def setUp(self):
labhub_info_path = (Path(__file__)
.parent / '..' / 'plugins' / 'labhub.plug')
with labhub_info_path.open() as plugfile:
labhub_info = PluginInfo.load_file(plugfile, labhub_info_path)
add_plugin_templates_path(labhub_info)

plugins.labhub.github3 = create_autospec(github3)

self.mock_org = create_autospec(github3.orgs.Organization)
Expand All @@ -47,7 +57,8 @@ def test_invite_cmd(self):
'coala developers': mock_team_developers
}

labhub, testbot = plugin_testbot(plugins.labhub.LabHub, logging.ERROR)
labhub, testbot = plugin_testbot(
plugins.labhub.LabHub, 'LabHub', logging.ERROR)
labhub.activate()
labhub._teams = teams

Expand Down Expand Up @@ -133,7 +144,7 @@ def test_create_issue_cmd(self):
plugins.labhub.GitLabPrivateToken = create_autospec(IGitt.GitLab.GitLabPrivateToken)

labhub, testbot_private = plugin_testbot(
plugins.labhub.LabHub, logging.ERROR,
plugins.labhub.LabHub, 'LabHub', logging.ERROR,
{'BACKEND': 'text', 'ACCESS_CONTROLS':{'create_issue_cmd' : {'allowprivate':False}}}
)
labhub.activate()
Expand All @@ -149,7 +160,7 @@ def test_create_issue_cmd(self):

# Creating issue in public chat
labhub, testbot_public = plugin_testbot(
plugins.labhub.LabHub, logging.ERROR, {'BACKEND': 'text'}
plugins.labhub.LabHub, 'LabHub', logging.ERROR, {'BACKEND': 'text'}
)
labhub.activate()
labhub.REPOS = {'repository': self.mock_repo,
Expand Down Expand Up @@ -182,7 +193,8 @@ def test_is_newcomer_issue(self):
def test_unassign_cmd(self):
plugins.labhub.GitHub = create_autospec(IGitt.GitHub.GitHub.GitHub)
plugins.labhub.GitLab = create_autospec(IGitt.GitLab.GitLab.GitLab)
labhub, testbot = plugin_testbot(plugins.labhub.LabHub, logging.ERROR)
labhub, testbot = plugin_testbot(
plugins.labhub.LabHub, 'LabHub', logging.ERROR)

labhub.activate()
labhub.REPOS = {'name': self.mock_repo}
Expand Down Expand Up @@ -211,7 +223,8 @@ def test_unassign_cmd(self):
def test_assign_cmd(self):
plugins.labhub.GitHub = create_autospec(IGitt.GitHub.GitHub.GitHub)
plugins.labhub.GitLab = create_autospec(IGitt.GitLab.GitLab.GitLab)
labhub, testbot = plugin_testbot(plugins.labhub.LabHub, logging.ERROR)
labhub, testbot = plugin_testbot(
plugins.labhub.LabHub, 'LabHub', logging.ERROR)
labhub.activate()

mock_issue = create_autospec(GitHubIssue)
Expand Down Expand Up @@ -322,7 +335,8 @@ def test_assign_cmd(self):
'not eligible to be assigned to this issue')

def test_mark_cmd(self):
labhub, testbot = plugin_testbot(plugins.labhub.LabHub, logging.ERROR)
labhub, testbot = plugin_testbot(
plugins.labhub.LabHub, 'LabHub', logging.ERROR)
labhub.activate()

labhub.REPOS = {'a': self.mock_repo}
Expand Down Expand Up @@ -376,7 +390,8 @@ def test_mark_cmd(self):
'marked pending review')

def test_alive(self):
labhub, testbot = plugin_testbot(plugins.labhub.LabHub, logging.ERROR)
labhub, testbot = plugin_testbot(
plugins.labhub.LabHub, 'LabHub', logging.ERROR)
with patch('plugins.labhub.time.sleep') as mock_sleep:
labhub.gh_repos = {
'coala': create_autospec(IGitt.GitHub.GitHub.GitHubRepository),
Expand Down

0 comments on commit f9e7c7e

Please sign in to comment.