def test_create_reply_with_message(self):
        from wechatpy.enterprise.messages import TextMessage

        msg = TextMessage({
            'FromUserName': '******',
            'ToUserName': '******',
            'AgentID': 1,
        })
        reply = create_reply('test', msg, render=False)

        self.assertEqual('user1', reply.target)
        self.assertEqual('user2', reply.source)
        self.assertEqual(1, reply.agent)
    def test_create_reply_with_message(self):
        from wechatpy.enterprise.messages import TextMessage

        msg = TextMessage({
            'FromUserName': '******',
            'ToUserName': '******',
            'AgentID': 1,
        })
        reply = create_reply('test', msg, render=False)

        self.assertEqual('user1', reply.target)
        self.assertEqual('user2', reply.source)
        self.assertEqual(1, reply.agent)
 def test_create_reply_with_articles(self):
     articles = [
         {
             'title': 'test 1',
             'description': 'test 1',
             'image': 'http://www.qq.com/1.png',
             'url': 'http://www.qq.com/1'
         },
         {
             'title': 'test 2',
             'description': 'test 2',
             'image': 'http://www.qq.com/2.png',
             'url': 'http://www.qq.com/2'
         },
         {
             'title': 'test 3',
             'description': 'test 3',
             'image': 'http://www.qq.com/3.png',
             'url': 'http://www.qq.com/3'
         },
     ]
     reply = create_reply(articles, render=False)
     self.assertEqual('news', reply.type)
 def test_create_reply_with_articles(self):
     articles = [
         {
             'title': 'test 1',
             'description': 'test 1',
             'image': 'http://www.qq.com/1.png',
             'url': 'http://www.qq.com/1'
         },
         {
             'title': 'test 2',
             'description': 'test 2',
             'image': 'http://www.qq.com/2.png',
             'url': 'http://www.qq.com/2'
         },
         {
             'title': 'test 3',
             'description': 'test 3',
             'image': 'http://www.qq.com/3.png',
             'url': 'http://www.qq.com/3'
         },
     ]
     reply = create_reply(articles, render=False)
     self.assertEqual('news', reply.type)
 def test_create_reply_with_text_not_render(self):
     text = 'test'
     reply = create_reply(text, render=False)
     self.assertEqual('text', reply.type)
     self.assertEqual(text, reply.content)
     self.assertEqual(0, reply.agent)
    def test_create_reply_with_reply(self):
        _reply = TextReply(content='test')
        reply = create_reply(_reply, render=False)

        self.assertEqual(_reply, reply)
 def test_create_reply_should_return_none(self):
     reply = create_reply(None)
     self.assertTrue(reply is None)
 def test_create_reply_with_text_render(self):
     text = 'test'
     reply = create_reply(text, render=True)
     self.assertTrue(isinstance(reply, six.text_type))
    def test_create_reply_with_reply(self):
        _reply = TextReply(content='test')
        reply = create_reply(_reply, render=False)

        self.assertEqual(_reply, reply)
 def test_create_reply_should_return_none(self):
     reply = create_reply(None)
     self.assertTrue(reply is None)
 def test_create_reply_with_text_render(self):
     text = 'test'
     reply = create_reply(text, render=True)
     self.assertTrue(isinstance(reply, six.text_type))
 def test_create_reply_with_text_not_render(self):
     text = 'test'
     reply = create_reply(text, render=False)
     self.assertEqual('text', reply.type)
     self.assertEqual(text, reply.content)
     self.assertEqual(0, reply.agent)