-
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DO NOT PUSH - plugins: plugin specific exceptions
- Loading branch information
Showing
4 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# coding=utf-8 | ||
from __future__ import unicode_literals, absolute_import, print_function, division | ||
|
||
|
||
class PluginError(Exception): | ||
pass | ||
|
||
|
||
class PluginNotFound(PluginError): | ||
def __init__(self, name): | ||
message = 'Plugin "%s" not found' | ||
super(PluginError, self).__init__(message) | ||
|
||
|
||
class PluginNotRegistered(PluginError): | ||
def __init__(self, name): | ||
message = 'Plugin "%s" not registered' | ||
super(PluginError, self).__init__(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# coding=utf-8 | ||
"""Tests for core ``sopel.bot`` module""" | ||
from __future__ import unicode_literals, absolute_import, print_function, division | ||
|
||
import pytest | ||
|
||
from sopel import bot, config, plugins | ||
|
||
|
||
@pytest.fixture | ||
def tmpconfig(tmpdir): | ||
conf_file = tmpdir.join('conf.ini') | ||
conf_file.write("\n".join([ | ||
"[core]", | ||
"owner=testnick", | ||
"nick = TestBot", | ||
"enable = coretasks" | ||
"" | ||
])) | ||
return config.Config(conf_file.strpath) | ||
|
||
|
||
def test_remove_plugin_unregistered_plugin(tmpconfig): | ||
sopel = bot.Sopel(tmpconfig, daemon=False) | ||
plugin = sopel._plugins.get('coretasks') | ||
|
||
assert plugin is not None, 'coretasks should be always loaded' | ||
|
||
# Unregister the plugin | ||
plugin.unregister(sopel) | ||
# And now it must raises | ||
with pytest.raises(plugins.PluginNotRegistered): | ||
sopel.remove_plugin(plugin, [], [], [], []) | ||
|
||
|
||
def test_reload_plugin_unregistered_plugin(tmpconfig): | ||
sopel = bot.Sopel(tmpconfig, daemon=False) | ||
plugin = sopel._plugins.get('coretasks') | ||
|
||
assert plugin is not None, 'coretasks should be always loaded' | ||
|
||
# Unregister the plugin | ||
plugin.unregister(sopel) | ||
# And now it must raises | ||
with pytest.raises(plugins.PluginNotRegistered): | ||
sopel.reload_plugin(plugin.name) |