1 from sleekxmpp
.test
import *
2 import sleekxmpp
.plugins
.xep_0033
as xep_0033
5 class TestAddresses(SleekTest
):
8 register_stanza_plugin(Message
, xep_0033
.Addresses
)
10 def testAddAddress(self
):
11 """Testing adding extended stanza address."""
13 msg
['addresses'].addAddress(atype
='to', jid
='to@header1.org')
16 <addresses xmlns="http://jabber.org/protocol/address">
17 <address jid="to@header1.org" type="to" />
23 msg
['addresses'].addAddress(atype
='replyto',
24 jid
='replyto@header1.org',
28 <addresses xmlns="http://jabber.org/protocol/address">
29 <address jid="replyto@header1.org" type="replyto" desc="Reply address" />
34 def testAddAddresses(self
):
35 """Testing adding multiple extended stanza addresses."""
39 <addresses xmlns="http://jabber.org/protocol/address">
40 <address jid="replyto@header1.org" type="replyto" desc="Reply address" />
41 <address jid="cc@header2.org" type="cc" />
42 <address jid="bcc@header2.org" type="bcc" />
48 msg
['addresses'].setAddresses([
50 'jid':'replyto@header1.org',
51 'desc':'Reply address'},
53 'jid':'cc@header2.org'},
55 'jid':'bcc@header2.org'}])
56 self
.check(msg
, xmlstring
)
59 msg
['addresses']['replyto'] = [{'jid':'replyto@header1.org',
60 'desc':'Reply address'}]
61 msg
['addresses']['cc'] = [{'jid':'cc@header2.org'}]
62 msg
['addresses']['bcc'] = [{'jid':'bcc@header2.org'}]
63 self
.check(msg
, xmlstring
)
66 """Testing adding URI attribute to extended stanza address."""
69 addr
= msg
['addresses'].addAddress(atype
='to',
74 <addresses xmlns="http://jabber.org/protocol/address">
75 <address node="foo" jid="to@header1.org" type="to" />
80 addr
['uri'] = 'mailto:to@header2.org'
83 <addresses xmlns="http://jabber.org/protocol/address">
84 <address type="to" uri="mailto:to@header2.org" />
89 def testDelivered(self
):
90 """Testing delivered attribute of extended stanza addresses."""
94 <addresses xmlns="http://jabber.org/protocol/address">
95 <address %s jid="to@header1.org" type="to" />
101 addr
= msg
['addresses'].addAddress(jid
='to@header1.org', atype
='to')
102 self
.check(msg
, xmlstring
% '')
104 addr
['delivered'] = True
105 self
.check(msg
, xmlstring
% 'delivered="true"')
107 addr
['delivered'] = False
108 self
.check(msg
, xmlstring
% '')
111 suite
= unittest
.TestLoader().loadTestsFromTestCase(TestAddresses
)