from . sleektest import * import sleekxmpp.plugins.xep_0033 as xep_0033 class TestAddresses(SleekTest): def setUp(self): registerStanzaPlugin(Message, xep_0033.Addresses) def testAddAddress(self): """Testing adding extended stanza address.""" msg = self.Message() msg['addresses'].addAddress(atype='to', jid='to@header1.org') self.checkMessage(msg, """
""") msg = self.Message() msg['addresses'].addAddress(atype='replyto', jid='replyto@header1.org', desc='Reply address') self.checkMessage(msg, """
""") def testAddAddresses(self): """Testing adding multiple extended stanza addresses.""" xmlstring = """
""" msg = self.Message() msg['addresses'].setAddresses([ {'type':'replyto', 'jid':'replyto@header1.org', 'desc':'Reply address'}, {'type':'cc', 'jid':'cc@header2.org'}, {'type':'bcc', 'jid':'bcc@header2.org'}]) self.checkMessage(msg, xmlstring) msg = self.Message() msg['addresses']['replyto'] = [{'jid':'replyto@header1.org', 'desc':'Reply address'}] msg['addresses']['cc'] = [{'jid':'cc@header2.org'}] msg['addresses']['bcc'] = [{'jid':'bcc@header2.org'}] self.checkMessage(msg, xmlstring) def testAddURI(self): """Testing adding URI attribute to extended stanza address.""" msg = self.Message() addr = msg['addresses'].addAddress(atype='to', jid='to@header1.org', node='foo') self.checkMessage(msg, """
""") addr['uri'] = 'mailto:to@header2.org' self.checkMessage(msg, """
""") def testDelivered(self): """Testing delivered attribute of extended stanza addresses.""" xmlstring = """
""" msg = self.Message() addr = msg['addresses'].addAddress(jid='to@header1.org', atype='to') self.checkMessage(msg, xmlstring % '') addr['delivered'] = True self.checkMessage(msg, xmlstring % 'delivered="true"') addr['delivered'] = False self.checkMessage(msg, xmlstring % '') suite = unittest.TestLoader().loadTestsFromTestCase(TestAddresses)