diff options
author | Lance Stout <lancestout@gmail.com> | 2010-10-07 10:58:13 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2010-10-07 10:58:13 -0400 |
commit | 0fffbb82000a1a6c3c23d62fedcbd8e8141f8994 (patch) | |
tree | 114c3767ccc13de3d0388b43cd357b90334f469a /tests/test_stanza_xep_0033.py | |
parent | 21c32c6e1cfd9b18e4c8320e0796e1d7e4b3f74c (diff) | |
download | slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.gz slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.bz2 slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.tar.xz slixmpp-0fffbb82000a1a6c3c23d62fedcbd8e8141f8994.zip |
Unit test reorganization.
Moved SleekTest to sleekxmpp.test.
Organized test suites by their focus.
- Suites focused on testing stanza objects are named test_stanza_X.py
- Suites focused on testing stream behavior are name test_stream_X.py
Diffstat (limited to 'tests/test_stanza_xep_0033.py')
-rw-r--r-- | tests/test_stanza_xep_0033.py | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/tests/test_stanza_xep_0033.py b/tests/test_stanza_xep_0033.py new file mode 100644 index 00000000..90f6374a --- /dev/null +++ b/tests/test_stanza_xep_0033.py @@ -0,0 +1,111 @@ +from sleekxmpp.test 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.check_message(msg, """ + <message> + <addresses xmlns="http://jabber.org/protocol/address"> + <address jid="to@header1.org" type="to" /> + </addresses> + </message> + """) + + msg = self.Message() + msg['addresses'].addAddress(atype='replyto', + jid='replyto@header1.org', + desc='Reply address') + self.check_message(msg, """ + <message> + <addresses xmlns="http://jabber.org/protocol/address"> + <address jid="replyto@header1.org" type="replyto" desc="Reply address" /> + </addresses> + </message> + """) + + def testAddAddresses(self): + """Testing adding multiple extended stanza addresses.""" + + xmlstring = """ + <message> + <addresses xmlns="http://jabber.org/protocol/address"> + <address jid="replyto@header1.org" type="replyto" desc="Reply address" /> + <address jid="cc@header2.org" type="cc" /> + <address jid="bcc@header2.org" type="bcc" /> + </addresses> + </message> + """ + + 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.check_message(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.check_message(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.check_message(msg, """ + <message> + <addresses xmlns="http://jabber.org/protocol/address"> + <address node="foo" jid="to@header1.org" type="to" /> + </addresses> + </message> + """) + + addr['uri'] = 'mailto:to@header2.org' + self.check_message(msg, """ + <message> + <addresses xmlns="http://jabber.org/protocol/address"> + <address type="to" uri="mailto:to@header2.org" /> + </addresses> + </message> + """) + + def testDelivered(self): + """Testing delivered attribute of extended stanza addresses.""" + + xmlstring = """ + <message> + <addresses xmlns="http://jabber.org/protocol/address"> + <address %s jid="to@header1.org" type="to" /> + </addresses> + </message> + """ + + msg = self.Message() + addr = msg['addresses'].addAddress(jid='to@header1.org', atype='to') + self.check_message(msg, xmlstring % '') + + addr['delivered'] = True + self.check_message(msg, xmlstring % 'delivered="true"') + + addr['delivered'] = False + self.check_message(msg, xmlstring % '') + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestAddresses) |