(self)
| 589 | self.assertEqual(resp['xml']['Music']['HQMusicUrl'], 'http://baidu.com/') |
| 590 | |
| 591 | def test_response_news(self): |
| 592 | wechat = WechatBasic() |
| 593 | wechat.parse_data(data=self.test_message) |
| 594 | |
| 595 | resp_xml = wechat.response_news(articles=[ |
| 596 | { |
| 597 | 'title': '第一条新闻标题', |
| 598 | 'description': '第一条新闻描述,这条新闻没有预览图', |
| 599 | 'url': 'http://www.google.com.hk/', |
| 600 | }, { |
| 601 | 'title': '第二条新闻标题, 这条新闻无描述', |
| 602 | 'picurl': 'http://doraemonext.oss-cn-hangzhou.aliyuncs.com/test/wechat-test.jpg', |
| 603 | 'url': 'http://www.github.com/', |
| 604 | }, { |
| 605 | 'title': '第三条新闻标题', |
| 606 | 'description': '第三条新闻描述', |
| 607 | 'picurl': 'http://doraemonext.oss-cn-hangzhou.aliyuncs.com/test/wechat-test.jpg', |
| 608 | 'url': 'http://www.v2ex.com/', |
| 609 | } |
| 610 | ]) |
| 611 | resp = xmltodict.parse(resp_xml) |
| 612 | |
| 613 | self.assertEqual(resp['xml']['ToUserName'], 'fromUser') |
| 614 | self.assertEqual(resp['xml']['FromUserName'], 'toUser') |
| 615 | self.assertEqual(resp['xml']['MsgType'], 'news') |
| 616 | self.assertEqual(resp['xml']['ArticleCount'], '3') |
| 617 | |
| 618 | self.assertEqual(resp['xml']['Articles']['item'][0]['Title'], '第一条新闻标题') |
| 619 | self.assertEqual(resp['xml']['Articles']['item'][0]['Description'], '第一条新闻描述,这条新闻没有预览图') |
| 620 | self.assertEqual(resp['xml']['Articles']['item'][0]['Url'], 'http://www.google.com.hk/') |
| 621 | self.assertIsNone(resp['xml']['Articles']['item'][0]['PicUrl']) |
| 622 | |
| 623 | self.assertEqual(resp['xml']['Articles']['item'][1]['Title'], '第二条新闻标题, 这条新闻无描述') |
| 624 | self.assertIsNone(resp['xml']['Articles']['item'][1]['Description']) |
| 625 | self.assertEqual(resp['xml']['Articles']['item'][1]['Url'], 'http://www.github.com/') |
| 626 | self.assertEqual(resp['xml']['Articles']['item'][1]['PicUrl'], 'http://doraemonext.oss-cn-hangzhou.aliyuncs.com/test/wechat-test.jpg') |
| 627 | |
| 628 | self.assertEqual(resp['xml']['Articles']['item'][2]['Title'], '第三条新闻标题') |
| 629 | self.assertEqual(resp['xml']['Articles']['item'][2]['Description'], '第三条新闻描述') |
| 630 | self.assertEqual(resp['xml']['Articles']['item'][2]['Url'], 'http://www.v2ex.com/') |
| 631 | self.assertEqual(resp['xml']['Articles']['item'][2]['PicUrl'], 'http://doraemonext.oss-cn-hangzhou.aliyuncs.com/test/wechat-test.jpg') |
| 632 | |
| 633 | def test_group_transfer_message(self): |
| 634 | wechat = WechatBasic() |
nothing calls this directly
no test coverage detected