@@ -105,6 +105,101 @@ def test_installed_plugins(self, mock_config, mock_path, mock_sys):
105105
106106 self .assertListEqual (result , ['plugin' ])
107107
108+ @patch ('plugin_manager.sys' )
109+ @patch ('plugin_manager.path' )
110+ @patch ('plugin_manager.ConfigurationManager' )
111+ def test_de_map_plugin_packets (self , mock_config , mock_path , mock_sys ):
112+ mock_plugin = Mock ()
113+ mock_plugin .name = 'Test'
114+
115+ pm = PluginManager (Mock ())
116+ pm .packets = {
117+ 1 : {
118+ 'on' : {
119+ 'Test' : 'remove me'
120+ },
121+ 'after' : {'Test2' : 'test' }
122+ },
123+ 2 : {
124+ 'on' : {
125+ 'Test' : 'remove me' ,
126+ 'Test3' : 'test'
127+ },
128+ 'after' : {
129+ 'Test' : 'remove me'
130+ },
131+ }
132+ }
133+ pm .de_map_plugin_packets (mock_plugin )
134+ self .assertDictEqual (
135+ pm .packets ,
136+ {
137+ 1 : {
138+ 'on' : {},
139+ 'after' : {'Test2' : 'test' }
140+ },
141+ 2 : {
142+ 'on' : {
143+ 'Test3' : 'test'
144+ },
145+ 'after' : {},
146+ }
147+ }
148+ )
149+
150+ @patch ('plugin_manager.sys' )
151+ @patch ('plugin_manager.path' )
152+ @patch ('plugin_manager.ConfigurationManager' )
153+ def test_map_plugin_packets (self , mock_config , mock_path , mock_sys ):
154+ mock_plugin = Mock ()
155+ mock_plugin .name = 'Test'
156+ mock_plugin .overridden_packets = {
157+ 1 : {
158+ 'on' : 'add me on 1' ,
159+ 'after' : 'add me after 1'
160+ }
161+ }
162+ mock_plugin2 = Mock ()
163+ mock_plugin2 .name = 'Test2'
164+ mock_plugin2 .overridden_packets = {
165+ 2 : {
166+ 'on' : 'add me on 2'
167+ },
168+ 3 : {
169+ 'after' : 'add me after 2'
170+ }
171+ }
172+
173+ pm = PluginManager (Mock ())
174+ pm .map_plugin_packets (mock_plugin )
175+
176+ self .assertDictEqual (
177+ pm .packets ,
178+ {
179+ 1 : {
180+ 'on' : {'Test' : (mock_plugin , 'add me on 1' )},
181+ 'after' : {'Test' : (mock_plugin , 'add me after 1' )}
182+ }
183+ }
184+ )
185+
186+ pm .map_plugin_packets (mock_plugin2 )
187+ self .assertDictEqual (
188+ pm .packets ,
189+ {
190+ 1 : {
191+ 'on' : {'Test' : (mock_plugin , 'add me on 1' )},
192+ 'after' : {'Test' : (mock_plugin , 'add me after 1' )}
193+ },
194+ 2 : {
195+ 'on' : {'Test2' : (mock_plugin2 , 'add me on 2' )}
196+ },
197+ 3 : {
198+ 'after' : {'Test2' : (mock_plugin2 , 'add me after 2' )}
199+ }
200+ }
201+ )
202+
108203
109204class RouteTestCase (TestCase ):
110205 @patch ('plugin_manager.reactor' )
0 commit comments