def test_noID(self): """ Test that a proper response is generated without id attribute. """ stanza = domish.Element(('jabber:client', 'message')) response = toResponse(stanza) self.failIf(response.hasAttribute('id'))
def test_toResponseNoAddressing(self): """ Test that a response is generated from a stanza without any addressing. """ stanza = domish.Element(('jabber:client', 'message')) stanza['type'] = 'chat' response = toResponse(stanza) self.failIf(response.hasAttribute('to')) self.failIf(response.hasAttribute('from'))
def test_toResponseNoTo(self): """ Test that a response is generated from a stanza without a to address. """ stanza = domish.Element(('jabber:client', 'iq')) stanza['type'] = 'get' stanza['from'] = '[email protected]/resource' response = toResponse(stanza) self.failIf(response.hasAttribute('from')) self.assertEqual(response['to'], '[email protected]/resource')
def test_toResponse(self): """ Test that a response stanza is generated with addressing swapped. """ stanza = domish.Element(('jabber:client', 'iq')) stanza['type'] = 'get' stanza['to'] = '*****@*****.**' stanza['from'] = '[email protected]/resource' stanza['id'] = 'stanza1' response = toResponse(stanza, 'result') self.assertNotIdentical(stanza, response) self.assertEqual(response['from'], '*****@*****.**') self.assertEqual(response['to'], '[email protected]/resource') self.assertEqual(response['type'], 'result') self.assertEqual(response['id'], 'stanza1')