Beispiel #1
0
    def test_unicode_xhtml(self):
        txt = u"""<!-- look here to see what is supported : http://xmpp.org/extensions/xep-0071.html -->
        <html xmlns='http://jabber.org/protocol/xhtml-im'>
        <body>
        <p style='margin-top: 0; margin-bottom: 0; font-weight:bold'>Interpreted your query as ts:[63491946525039405 TO 63491946825039405]</p>
        <p style='margin-top: 0; margin-bottom: 0;'>2012-12-24 11:50:12 frigg : VERSION</p>
        <p style='margin-top: 0; margin-bottom: 0;'>2012-12-24 11:50:25 #err : !translate he en מחשב</p>
        <p style='margin-top: 0; margin-bottom: 0;'>2012-12-24 11:51:01 gbin : !echo é</p>
        <p style='margin-top: 0; margin-bottom: 0;'>2012-12-24 11:52:58 24926_143884 : !echo へようこそ </p>
        <p style='margin-top: 0; margin-bottom: 0;'>2012-12-24 11:53:26 24926_143884 : !status</p>
        <p style='margin-top: 0; margin-bottom: 0;'>2012-12-24 11:53:38 24926_143884 : !help TimeMachine</p>
        </body>
        </html>"""
        pure_expected_text = u'Interpreted your query as ts:[63491946525039405 TO 63491946825039405]\n' \
            u'        2012-12-24 11:50:12 frigg : *VERSION*\n        2012-12-24 11:50:25 #err : !translate he en \u05de\u05d7\u05e9\u05d1\n' \
            u'        2012-12-24 11:51:01 gbin : !echo \xe9\n        2012-12-24 11:52:58 24926_143884 : !echo \u3078\u3088\u3046\u3053\u305d \n' \
            u'        2012-12-24 11:53:26 24926_143884 : !status\n        2012-12-24 11:53:38 24926_143884 : !help TimeMachine'
        expected_clean_unicode = u"""<html xmlns="http://jabber.org/protocol/xhtml-im">
        <body>
        <p style="margin-top: 0; margin-bottom: 0; font-weight:bold">Interpreted your query as ts:[63491946525039405 TO 63491946825039405]</p>
        <p style="margin-top: 0; margin-bottom: 0;">2012-12-24 11:50:12 frigg : *VERSION*</p>
        <p style="margin-top: 0; margin-bottom: 0;">2012-12-24 11:50:25 #err : !translate he en מחשב</p>
        <p style="margin-top: 0; margin-bottom: 0;">2012-12-24 11:51:01 gbin : !echo é</p>
        <p style="margin-top: 0; margin-bottom: 0;">2012-12-24 11:52:58 24926_143884 : !echo へようこそ </p>
        <p style="margin-top: 0; margin-bottom: 0;">2012-12-24 11:53:26 24926_143884 : !status</p>
        <p style="margin-top: 0; margin-bottom: 0;">2012-12-24 11:53:38 24926_143884 : !help TimeMachine</p>
        </body>
        </html>"""

        self.maxDiff = None
        msg1 = build_message(txt, XMPPMessage)
        self.assertEquals(msg1.getBody(), pure_expected_text)
        #self.assertEquals(msg1.getNode('html'), txt)

        msg2 = build_message(txt, BaseMessage)
        self.assertEquals(msg2.getBody(), pure_expected_text)
        self.assertEquals(msg2.getHTML(), expected_clean_unicode)
Beispiel #2
0
 def build_message(self, text):
     return build_message(text, Message)
Beispiel #3
0
 def build_message(self, text):
     return build_message(text, Message)
Beispiel #4
0
 def build_message(self, text):
     return build_message(text, Message, xhtml2hipchat)