-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LabHub: Use activate and configuration templates #577
Conversation
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
Blocked until corobotestcase in plugins is implemented. |
Still relevant? |
Travis tests have failedHey @nvzard, |
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
plugins/labhub.py
Outdated
assert gh is not None | ||
except AssertionError: | ||
except AssertionError: # pragma: no cover, for logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
Origin: PEP8Bear, Section: all.autopep8
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpammsf7vp/plugins/labhub.py
+++ b/tmp/tmpammsf7vp/plugins/labhub.py
@@ -52,7 +52,7 @@
try:
gh = github3.login(token=self.config['GH_TOKEN'])
assert gh is not None
- except AssertionError: # pragma: no cover, for logging
+ except AssertionError: # pragma: no cover, for logging
self.log.error('Cannot create github object, please check GH_TOKEN')
else:
self.GH3_ORG = gh.organization(self.config['GH_ORG_NAME'])
plugins/labhub.py
Outdated
self.IGH.write_repositories)} | ||
except RuntimeError: | ||
except RuntimeError: # pragma: no cover, for logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
Origin: PEP8Bear, Section: all.autopep8
.
The issue can be fixed by applying the following patch:
--- a/tmp/tmpammsf7vp/plugins/labhub.py
+++ b/tmp/tmpammsf7vp/plugins/labhub.py
@@ -71,7 +71,7 @@
filter(lambda x: (x.full_name.split('/')[0] ==
self.config['GH_ORG_NAME']),
self.IGH.write_repositories)}
- except RuntimeError: # pragma: no cover, for logging
+ except RuntimeError: # pragma: no cover, for logging
self.log.exception('Something went wrong in fetching github repos.')
else:
self.REPOS.update(self.gh_repos)
plugins/labhub.py
Outdated
assert gh is not None | ||
except AssertionError: | ||
except AssertionError: # pragma: no cover, for logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E261 at least two spaces before inline comment
Origin: PycodestyleBear (E261), Section: all.autopep8
.
Travis tests have failedHey @nvzard, 1st Buildcoala --non-interactive -V
python -m pytest
|
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
tests/isolated_testcase.py
Outdated
|
||
def setUp(self, extra_config=None): | ||
file_name = 'labhub.plug' | ||
file_rename = 'hidden' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do class initialisation in setUpClass
, including creating the hidden directory , and then remove the directory in tearDownClass
.
2be746e
to
901c2f6
Compare
Travis tests have failedHey @nvzard, 1st Buildpython -m pytest
|
277b189
to
b0e5fb3
Compare
tests/nevermind_test.py
Outdated
"!hey nEverMINd", 'Command "hey" / "hey nEverMINd" not found.') | ||
class NevermindTest(IsolatedTestCase): | ||
def test_nevermind(self): | ||
self.assertCommand("!nevermind", "I'm sorry :(") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert to single quotes
tests/nevermind_test.py
Outdated
self.assertCommand("!hey nM", 'Command "hey" / "hey nM" not found.') | ||
self.assertCommand("!nevermindxyz", 'Command "nevermindxyz" not found.') | ||
self.assertCommand( | ||
"!hey nEverMINd", 'Command "hey" / "hey nEverMINd" not found.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split into two lines
tests/ship_it_test.py
Outdated
class ShipItTest(IsolatedTestCase): | ||
def test_ship_it(self): | ||
text = errbot.rendering.text() | ||
self.assertCommand("!shipit", text.convert("![ship it!]()")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
tests/spam_test.py
Outdated
|
||
def test_spam_callback(self): | ||
self.testbot.assertCommand('c'*1001, 'you\'re spamming') | ||
self.testbot.assertCommand('\n\n'*11, 'you\'re spamming') | ||
self.assertCommand('c'*1001, 'you\'re spamming') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add instance variable self.testbot = self
@@ -43,30 +33,24 @@ def setUp(self): | |||
} | |||
} | |||
} | |||
self.testbot = TestBot(extra_plugin_dir='plugins', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.testbot = self
tests/ghetto_test.py
Outdated
testbot.assertCommand("!ghetto ...", "Shiznit happens!") | ||
@vcr.use_cassette('tests/cassettes/ghetto.yaml') | ||
def test_ghetto(self): | ||
self.assertCommand("!ghetto hi, whats up?", "hi, wassup?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
tests/ghetto_test.py
Outdated
with requests_mock.Mocker() as m: | ||
m.register_uri('POST', 'http://www.gizoogle.net/textilizer.php', | ||
text='test text which will not match with the regex') | ||
self.assertCommand("!ghetto ...", "Shiznit happens!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single quotes
@@ -65,7 +68,7 @@ def __init__(self, bot, name=None): | |||
filter(lambda x: (x.full_name.split('/')[0] == | |||
self.GH_ORG_NAME), | |||
self.IGH.write_repositories)} | |||
except RuntimeError: | |||
except RuntimeError: # pragma: no cover, for logging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to use requests-mock to break IGitt so it gives a RuntimeError , but ... not critical ... this is OK for now
b0e5fb3
to
112fbb4
Compare
IsolatedTestCase prevents TestBot from loading LabHub as IGitt imports were delaying loading time for the bot due to repetitive attempts to send requests until an HTTP Client Error is raised. It was also not possible to patch the IGitt imports while testing these plugins as plugins in Errbot are loaded dynamically using yapsy plugin manager. So it is not possible to patch since the namespace is unknown. IsolatedTestCase is able to prevent loading of labhub plugin by renaming its `.plug` file. This prevents the TestBot from loading it.
112fbb4
to
e302640
Compare
ack e302640 |
@gitmate-bot ff |
Hey! I'm GitMate.io! This pull request is being fastforwarded automatically. Please DO NOT push while fastforward is in progress or your changes would be lost permanently |
Automated fastforward with GitMate.io was successful! 🎉 |
__init__
is executed at load time andand any issue in the plugin will lead
to it not showing up.
LifeCycle:
__init__
->configured->enableAdapts to the
DefaultConfigMixin
andmigrated to using configuration templates.
Closes #554
Closes #382