2 from slixmpp
.test
import SlixTest
3 from slixmpp
.stanza
.message
import Message
4 from slixmpp
.stanza
.htmlim
import HTMLIM
5 from slixmpp
.xmlstream
import register_stanza_plugin
8 class TestMessageStanzas(SlixTest
):
11 register_stanza_plugin(Message
, HTMLIM
)
13 def testGroupchatReplyRegression(self
):
14 "Regression groupchat reply should be to barejid"
16 msg
['to'] = 'me@myserver.tld'
17 msg
['from'] = 'room@someservice.someserver.tld/somenick'
18 msg
['type'] = 'groupchat'
19 msg
['body'] = "this is a message"
21 self
.failUnless(str(msg
['to']) == 'room@someservice.someserver.tld')
23 def testAttribProperty(self
):
24 "Test attrib property returning self"
26 msg
.attrib
.attrib
.attrib
['to'] = 'usr@server.tld'
27 self
.failUnless(str(msg
['to']) == 'usr@server.tld')
29 def testHTMLPlugin(self
):
30 "Test message/html/body stanza"
32 msg
['to'] = "fritzy@netflint.net/slixmpp"
33 msg
['body'] = "this is the plaintext message"
35 msg
['html']['body'] = '<p>This is the htmlim message</p>'
37 <message to="fritzy@netflint.net/slixmpp" type="chat">
38 <body>this is the plaintext message</body>
39 <html xmlns="http://jabber.org/protocol/xhtml-im">
40 <body xmlns="http://www.w3.org/1999/xhtml">
41 <p>This is the htmlim message</p>
46 def testNickPlugin(self
):
47 "Test message/nick/nick stanza."
49 msg
['nick']['nick'] = 'A nickname!'
52 <nick xmlns="http://jabber.org/protocol/nick">A nickname!</nick>
57 suite
= unittest
.TestLoader().loadTestsFromTestCase(TestMessageStanzas
)