slixmpp/tests/test_stanza_xep_0184.py

42 lines
1,003 B
Python
Raw Normal View History

2013-07-26 11:02:26 +00:00
import unittest
from sleekxmpp import Message
from sleekxmpp.test import SleekTest
2012-02-02 13:29:27 +00:00
import sleekxmpp.plugins.xep_0184 as xep_0184
2013-07-26 11:02:26 +00:00
from sleekxmpp.xmlstream import register_stanza_plugin
2012-02-02 13:29:27 +00:00
class TestReciept(SleekTest):
def setUp(self):
register_stanza_plugin(Message, xep_0184.Request)
register_stanza_plugin(Message, xep_0184.Received)
def testCreateRequest(self):
request = """
<message>
<request xmlns="urn:xmpp:receipts" />
</message>
"""
2012-02-02 13:29:27 +00:00
msg = self.Message()
self.assertEqual(msg['request_receipt'], False)
2012-02-02 13:29:27 +00:00
msg['request_receipt'] = True
self.check(msg, request)
2012-02-02 13:29:27 +00:00
def testCreateReceived(self):
received = """
<message>
<received xmlns="urn:xmpp:receipts" id="1" />
</message>
"""
2012-02-02 13:29:27 +00:00
msg = self.Message()
msg['receipt'] = '1'
2012-02-02 13:29:27 +00:00
self.check(msg, received)
2012-02-02 13:29:27 +00:00
suite = unittest.TestLoader().loadTestsFromTestCase(TestReciept)