diff options
author | David Rousselie <dax@happycoders.org> | 2008-03-07 13:39:17 +0300 |
---|---|---|
committer | David Rousselie <dax@happycoders.org> | 2008-03-07 13:39:17 +0300 |
commit | 7e759f9a20a93ac58c5481ed9c00d1c666ea5877 (patch) | |
tree | 3c50cf11578ad9a731ad1b8bc12c0f5c67c4f473 /src | |
parent | 6e46ad62b50ab0c1edd05b512a585eaf1cb1e10a (diff) |
Handle unknown error while exceuting ad-hoc commands
darcs-hash:20080307103917-86b55-1a8d6aceb8b412708913aa95ef2f374a88181b38.gz
Diffstat (limited to 'src')
-rw-r--r-- | src/jcl/jabber/command.py | 2 | ||||
-rw-r--r-- | src/jcl/jabber/tests/command.py | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/jcl/jabber/command.py b/src/jcl/jabber/command.py index 98f21f1..97be09a 100644 --- a/src/jcl/jabber/command.py +++ b/src/jcl/jabber/command.py @@ -274,6 +274,8 @@ class CommandManager(object): "feature-not-implemented")] except CommandError, error: return [info_query.make_error_response(error.type)] + except Exception: + return [info_query.make_error_response("service-unavailable")] def add_actions(self, command_node, actions, default_action_idx=0): actions_node = command_node.newTextChild(None, "actions", None) diff --git a/src/jcl/jabber/tests/command.py b/src/jcl/jabber/tests/command.py index 797493d..251ed5f 100644 --- a/src/jcl/jabber/tests/command.py +++ b/src/jcl/jabber/tests/command.py @@ -452,6 +452,37 @@ class CommandManager_TestCase(unittest.TestCase): + "</iq>", result_iq, True)) + def test_multi_step_command_unknown_error_in_command(self): + """ + Test if the multi steps method catch the CommandError exception + and translate it into an IQ error + """ + self.command_manager = MockCommandManager() + def execute_command1(info_query, session_context, + command_node, lang_class): + raise Exception("error") + + self.command_manager.__dict__["execute_command1_1"] = execute_command1 + info_query = Iq(stanza_type="set", + from_jid="user@test.com", + to_jid="jcl.test.com") + command_node = info_query.set_new_content(command.COMMAND_NS, + "command") + command_node.setProp("node", "command1") + result = self.command_manager.execute_multi_step_command(\ + info_query, "command1", None) + result_iq = result[0].xmlnode + self.assertTrue(jcl.tests.is_xml_equal(\ + u"<iq from='" + unicode(self.command_manager.component.jid) + + "' to='user@test.com' type='error' " + + "xmlns='http://pyxmpp.jabberstudio.org/xmlns/common'>" + + "<command xmlns='http://jabber.org/protocol/commands'" + + "node='command1' />" + + "<error type='cancel'><service-unavailable " + + "xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></error>" + + "</iq>", + result_iq, True)) + def test_parse_form(self): """ Check if parse_form method correctly set the session variables |