Esempio n. 1
0
 def test_text_message_to_json(self):
     msg = TextMessage('to_addr', 'from_addr', '1348831860',
                       'this is a test')
     self.assertEqual(
         json.loads(msg.to_json()), {
             'touser': '******',
             'msgtype': 'text',
             'text': {
                 'content': 'this is a test'
             }
         })
Esempio n. 2
0
 def test_text_message_to_json(self):
     msg = TextMessage(
         'to_addr', 'from_addr', '1348831860', 'this is a test')
     self.assertEqual(
         json.loads(msg.to_json()),
         {
             'touser': '******',
             'msgtype': 'text',
             'text': {
                 'content': 'this is a test'
             }
         })
Esempio n. 3
0
 def test_text_message_to_xml(self):
     msg = TextMessage('to_addr', 'from_addr', '1348831860',
                       'this is a test')
     self.assertEqual(
         msg.to_xml(), "".join([
             "<xml>",
             "<ToUserName>to_addr</ToUserName>",
             "<FromUserName>from_addr</FromUserName>",
             "<CreateTime>1348831860</CreateTime>",
             "<MsgType>text</MsgType>",
             "<Content>this is a test</Content>",
             "</xml>",
         ]))
Esempio n. 4
0
 def test_text_message_to_xml(self):
     msg = TextMessage(
         'to_addr', 'from_addr', '1348831860', 'this is a test')
     self.assertEqual(
         msg.to_xml(),
         "".join([
             "<xml>",
             "<ToUserName>to_addr</ToUserName>",
             "<FromUserName>from_addr</FromUserName>",
             "<CreateTime>1348831860</CreateTime>",
             "<MsgType>text</MsgType>",
             "<Content>this is a test</Content>",
             "</xml>",
         ]))