示例#1
0
 def test_typeRemoteServerTimeout(self):
     """
     Remote Server Timeout should yield type wait, code 504.
     """
     e = error.StanzaError('remote-server-timeout')
     self.assertEquals('wait', e.type)
     self.assertEquals('504', e.code)
示例#2
0
 def test_getElementTextNamespace(self):
     """
     Test that the error text element has the correct namespace.
     """
     e = error.StanzaError('feature-not-implemented', text='text')
     element = e.getElement()
     self.assertEquals(NS_XMPP_STANZAS, element.text.uri)
示例#3
0
 def test_getElementConditionNamespace(self):
     """
     Test that the error condition element has the correct namespace.
     """
     e = error.StanzaError('feature-not-implemented')
     element = e.getElement()
     self.assertEquals(NS_XMPP_STANZAS,
                       getattr(element, 'feature-not-implemented').uri)
示例#4
0
 def test_getElementPlain(self):
     """
     Test getting an element for a plain stanza error.
     """
     e = error.StanzaError('feature-not-implemented')
     element = e.getElement()
     self.assertEquals(element.uri, None)
     self.assertEquals(element['type'], 'cancel')
     self.assertEquals(element['code'], '501')
示例#5
0
 def test_getElementType(self):
     """
     Test getting an element for a stanza error with a given type.
     """
     e = error.StanzaError('feature-not-implemented', 'auth')
     element = e.getElement()
     self.assertEquals(element.uri, None)
     self.assertEquals(element['type'], 'auth')
     self.assertEquals(element['code'], '501')
示例#6
0
    def test_toResponse(self):
        """
        Test an error response is generated from a stanza.

        The addressing on the (new) response stanza should be reversed, an
        error child (with proper properties) added and the type set to
        C{'error'}.
        """
        stanza = domish.Element(('jabber:client', 'message'))
        stanza['type'] = 'chat'
        stanza['to'] = '*****@*****.**'
        stanza['from'] = '[email protected]/resource'
        e = error.StanzaError('service-unavailable')
        response = e.toResponse(stanza)
        self.assertNotIdentical(response, stanza)
        self.assertEqual(response['from'], '*****@*****.**')
        self.assertEqual(response['to'], '[email protected]/resource')
        self.assertEqual(response['type'], 'error')
        self.assertEqual(response.error.children[0].name,
                         'service-unavailable')
        self.assertEqual(response.error['type'], 'cancel')
        self.assertNotEqual(stanza.children, response.children)