|
|
@ -39,20 +39,26 @@ class BrokenModulesTest(unittest2.TestCase):
|
|
|
|
# Ensure we don't crash in the case of a module legitimately being
|
|
|
|
# Ensure we don't crash in the case of a module legitimately being
|
|
|
|
# unavailable. Should never happen in the real world.
|
|
|
|
# unavailable. Should never happen in the real world.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stream = mock.Mock()
|
|
|
|
|
|
|
|
stream.sent_modules = set()
|
|
|
|
router = mock.Mock()
|
|
|
|
router = mock.Mock()
|
|
|
|
responder = mitogen.master.ModuleResponder(router)
|
|
|
|
router.stream_by_id = lambda n: stream
|
|
|
|
responder._on_get_module(
|
|
|
|
|
|
|
|
mitogen.core.Message(
|
|
|
|
msg = mitogen.core.Message(
|
|
|
|
data='non_existent_module',
|
|
|
|
data='non_existent_module',
|
|
|
|
reply_to=50,
|
|
|
|
reply_to=50,
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
msg.router = router
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
responder = mitogen.master.ModuleResponder(router)
|
|
|
|
|
|
|
|
responder._on_get_module(msg)
|
|
|
|
self.assertEquals(1, len(router.route.mock_calls))
|
|
|
|
self.assertEquals(1, len(router.route.mock_calls))
|
|
|
|
|
|
|
|
|
|
|
|
call = router.route.mock_calls[0]
|
|
|
|
call = router.route.mock_calls[0]
|
|
|
|
msg, = call[1]
|
|
|
|
msg, = call[1]
|
|
|
|
self.assertEquals(50, msg.handle)
|
|
|
|
self.assertEquals(mitogen.core.LOAD_MODULE, msg.handle)
|
|
|
|
self.assertIsNone(msg.unpickle())
|
|
|
|
self.assertEquals(('non_existent_module', None, None, None, ()),
|
|
|
|
|
|
|
|
msg.unpickle())
|
|
|
|
|
|
|
|
|
|
|
|
def test_ansible_six_messed_up_path(self):
|
|
|
|
def test_ansible_six_messed_up_path(self):
|
|
|
|
# The copy of six.py shipped with Ansible appears in a package whose
|
|
|
|
# The copy of six.py shipped with Ansible appears in a package whose
|
|
|
@ -62,19 +68,24 @@ class BrokenModulesTest(unittest2.TestCase):
|
|
|
|
# cause an attempt to request ansible.compat.six._six from the master.
|
|
|
|
# cause an attempt to request ansible.compat.six._six from the master.
|
|
|
|
import six_brokenpkg
|
|
|
|
import six_brokenpkg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stream = mock.Mock()
|
|
|
|
|
|
|
|
stream.sent_modules = set()
|
|
|
|
router = mock.Mock()
|
|
|
|
router = mock.Mock()
|
|
|
|
responder = mitogen.master.ModuleResponder(router)
|
|
|
|
router.stream_by_id = lambda n: stream
|
|
|
|
responder._on_get_module(
|
|
|
|
|
|
|
|
mitogen.core.Message(
|
|
|
|
msg = mitogen.core.Message(
|
|
|
|
data='six_brokenpkg._six',
|
|
|
|
data='six_brokenpkg._six',
|
|
|
|
reply_to=50,
|
|
|
|
reply_to=50,
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
msg.router = router
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
responder = mitogen.master.ModuleResponder(router)
|
|
|
|
|
|
|
|
responder._on_get_module(msg)
|
|
|
|
self.assertEquals(1, len(router.route.mock_calls))
|
|
|
|
self.assertEquals(1, len(router.route.mock_calls))
|
|
|
|
|
|
|
|
|
|
|
|
call = router.route.mock_calls[0]
|
|
|
|
call = router.route.mock_calls[0]
|
|
|
|
msg, = call[1]
|
|
|
|
msg, = call[1]
|
|
|
|
self.assertEquals(50, msg.handle)
|
|
|
|
self.assertEquals(mitogen.core.LOAD_MODULE, msg.handle)
|
|
|
|
self.assertIsInstance(msg.unpickle(), tuple)
|
|
|
|
self.assertIsInstance(msg.unpickle(), tuple)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|