Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Commit

Permalink
[142] Fixing revert issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
8r2y5 committed Dec 15, 2015
1 parent fa422f3 commit 538ba50
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions base_plugin.py
Expand Up @@ -59,13 +59,13 @@ class BasePlugin(object):
active = False

def __init__(self, *args, **kwargs):
self.overridden_methods = {}
self.overridden_packets = {}
super(BasePlugin, self).__init__(*args, **kwargs)
if self.__class__.__name__ != 'BasePlugin':
for packet, when_dict in self.overridden_methods.iteritems():
self.overridden_methods.setdefault(packet, {})
self.overridden_packets.setdefault(packet, {})
for when, packet_name in when_dict.iteritems():
self.overridden_methods[packet][when] = getattr(
self.overridden_packets[packet][when] = getattr(
self, packet_name
)

Expand Down
2 changes: 1 addition & 1 deletion plugin_manager.py
Expand Up @@ -276,7 +276,7 @@ def map_plugin_packets(self, plugin):
"""
Maps plugin overridden packets ready to use in do method.
"""
for packet_id, when_dict in plugin.overridden_methods.iteritems():
for packet_id, when_dict in plugin.overridden_packets.iteritems():
for when, packet_method in when_dict.iteritems():
self.packets.setdefault(
packet_id, {}
Expand Down
6 changes: 3 additions & 3 deletions tests/test_base_plugin.py
Expand Up @@ -7,7 +7,7 @@ class BasePluginTestCase(TestCase):
def test_mapping_override_packets_dont_include_base_plugin(self):
base_plugin = BasePlugin()
with self.assertRaises(AttributeError):
base_plugin.overridden_packets
base_plugin.overridden_methods

def test_activation_deactivation(self):
class TestPlugin(BasePlugin):
Expand Down Expand Up @@ -40,7 +40,7 @@ def after_burn_container(self, data):
test_plugin = TestPlugin()
self.maxDiff = None
self.assertDictEqual(
test_plugin.overridden_methods,
test_plugin.overridden_packets,
{
5: {
'on': test_plugin.on_chat_received
Expand All @@ -51,7 +51,7 @@ def after_burn_container(self, data):
}
)
self.assertDictEqual(
test_plugin2.overridden_methods,
test_plugin2.overridden_packets,
{
44: {
'on': test_plugin2.on_burn_container,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin_manager.py
Expand Up @@ -153,15 +153,15 @@ def test_de_map_plugin_packets(self, mock_config, mock_path, mock_sys):
def test_map_plugin_packets(self, mock_config, mock_path, mock_sys):
mock_plugin = Mock()
mock_plugin.name = 'Test'
mock_plugin.overridden_methods = {
mock_plugin.overridden_packets = {
1: {
'on': 'add me on 1',
'after': 'add me after 1'
}
}
mock_plugin2 = Mock()
mock_plugin2.name = 'Test2'
mock_plugin2.overridden_methods = {
mock_plugin2.overridden_packets = {
2: {
'on': 'add me on 2'
},
Expand Down

0 comments on commit 538ba50

Please sign in to comment.