(self)
| 641 | self.assertEqual(resp['xml']['MsgType'], 'transfer_customer_service') |
| 642 | |
| 643 | def test_create_menu(self): |
| 644 | menu_info = { |
| 645 | 'button': [ |
| 646 | { |
| 647 | 'type': 'click', |
| 648 | 'name': '今日歌曲', |
| 649 | 'key': 'V1001_TODAY_MUSIC' |
| 650 | }, |
| 651 | { |
| 652 | 'type': 'click', |
| 653 | 'name': '歌手简介', |
| 654 | 'key': 'V1001_TODAY_SINGER' |
| 655 | }, |
| 656 | { |
| 657 | 'name': '菜单', |
| 658 | 'sub_button': [ |
| 659 | { |
| 660 | 'type': 'view', |
| 661 | 'name': '搜索', |
| 662 | 'url': 'http://www.soso.com/' |
| 663 | }, |
| 664 | { |
| 665 | 'type': 'view', |
| 666 | 'name': '视频', |
| 667 | 'url': 'http://v.qq.com/' |
| 668 | }, |
| 669 | { |
| 670 | 'type': 'click', |
| 671 | 'name': '赞一下我们', |
| 672 | 'key': 'V1001_GOOD' |
| 673 | } |
| 674 | ] |
| 675 | } |
| 676 | ] |
| 677 | } |
| 678 | |
| 679 | # 测试无 appid 和 appsecret 初始化 |
| 680 | wechat = WechatBasic() |
| 681 | with self.assertRaises(NeedParamError): |
| 682 | wechat.create_menu(menu_info) |
| 683 | |
| 684 | # 测试有 appid 和 appsecret 初始化 |
| 685 | wechat = WechatBasic(appid=self.appid, appsecret=self.appsecret) |
| 686 | with HTTMock(wechat_api_mock): |
| 687 | resp = wechat.create_menu(menu_info) |
| 688 | self.assertEqual(resp['errcode'], 0) |
| 689 | self.assertEqual(resp['errmsg'], 'ok') |
| 690 | |
| 691 | def test_get_menu(self): |
| 692 | # 测试无 appid 和 appsecret 初始化 |
nothing calls this directly
no test coverage detected