示例#1
0
    def test_custom_typing(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        res = custom_typing(OPENID, typing=True, appid=appid, secret=appsecret)
        assert isinstance(res, dict)
        assert res['errcode'] == 0
示例#2
0
    def test_try_match(self):
        """
        {u'errcode': 65303, u'errmsg': u'there is no selfmenu, please create selfmenu first hint: [kufg3a0431vr21]'}
        """
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        menu = Menu(appid=appid, secret=appsecret)
        menu.delete_menu()

        # 没有默认菜单,不能创建个性化菜单
        menu0 = menu.try_match(OPENID)
        assert isinstance(menu0, dict)
        assert menu0['errcode'] == 65303

        # 创建自定义菜单
        menu.create_menu(MENUS)
        # 创建个性化菜单
        menu.add_conditional(MENUS)

        menus1 = menu.try_match(OPENID)
        assert isinstance(menus1, dict)

        menus2 = try_match(OPENID, appid=appid, secret=appsecret)
        assert isinstance(menus2, dict)

        assert menus1 == menus2
示例#3
0
    def test_add_conditional(self):
        """
        {u'errcode': 0, u'errmsg': u'ok'}
        {u'errcode': 65303, u'errmsg': u'there is no selfmenu, please create selfmenu first hint: [kufg3a0431vr21]'}
        {u'errcode': 65304, u'errmsg': u'match rule empty hint: [.9S05a0657vr23]'}
        """
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        menu = Menu(appid=appid, secret=appsecret)

        # 没有默认菜单,不能创建个性化菜单
        menu0 = menu.try_match(OPENID)
        assert isinstance(menu0, dict)
        assert menu0['errcode'] == 65303

        # 创建自定义菜单
        menu.create_menu(MENUS)

        # MatchRule 信息为空
        menu1 = menu.add_conditional(MENUS)
        assert isinstance(menu1, dict)
        assert menu1['errcode'] == 65304

        menu2 = add_conditional(MENUS, appid=appid, secret=appsecret)
        assert isinstance(menu2, dict)
        assert menu2['errcode'] == 65304

        menu3 = menu.add_conditional(CONDITIONALMENUS)
        assert isinstance(menu3, dict)
        assert menu3['menuid']

        menu4 = add_conditional(CONDITIONALMENUS, appid=appid, secret=appsecret)
        assert isinstance(menu4, dict)
        assert menu4['menuid']
示例#4
0
    def test_del_conditional(self):
        """
        {u'errcode': 0, u'errmsg': u'ok'}
        {u'errcode': 65301, u'errmsg': u'this menu is not conditionalmenu hint: [JkV3pa0141vr25]'}
        """
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        menu = Menu(appid=appid, secret=appsecret)

        # 创建自定义菜单
        menu.create_menu(MENUS)

        # 不存在此 menuid 对应的个性化菜单
        menu0 = menu.delete_conditional('menuid')
        assert isinstance(menu0, dict)
        assert menu0['errcode'] == 65301

        menuid1 = menu.add_conditional(CONDITIONALMENUS)['menuid']
        menu1 = menu.del_conditional(menuid1)
        assert isinstance(menu1, dict)
        assert menu1['errcode'] == 0
        assert menu1['errmsg'] == 'ok'

        menuid2 = menu.add_conditional(CONDITIONALMENUS)['menuid']
        menu2 = del_conditional(menuid2, appid=appid, secret=appsecret)
        assert isinstance(menu2, dict)
        assert menu2['errcode'] == 0
        assert menu2['errmsg'] == 'ok'
示例#5
0
    def test_qrcode_create(self):
        """
        {
            "ticket":"gQH47joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL2taZ2Z3TVRtNzJXV1Brb3ZhYmJJAAIEZ23sUwMEmm3sUw==",
            "expire_seconds":60,
            "url":"http://weixin.qq.com/q/kZgfwMTm72WWPkovabbI"
        }
        """
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
        qrcode = QRCode(appid=appid, secret=appsecret)
        data = qrcode.create_scene(scene_id=0, expire_seconds=2592000)
        assert isinstance(data, dict)
        assert data.get('ticket', '')

        data = qrcode_str_scene(scene_str='pywe_qrcode', expire_seconds=2592000, appid=appid, secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('ticket', '')

        data = qrcode.create_limit_scene(scene_id=0)
        assert isinstance(data, dict)
        assert data.get('ticket', '')

        data = qrcode_limit_str_scene(scene_str='pywe_qrcode', appid=appid, secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('ticket', '')
示例#6
0
    def test_get_user_info(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        user = User(appid=appid, secret=appsecret)
        info = user.get_user_info(openid=OPENID)
        assert isinstance(info, dict)
        assert info['openid'] == OPENID
示例#7
0
    def test_send_custom_card_message(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        customsg = CustomMessage(appid=appid, secret=appsecret)
        res = customsg.send_custom_card_message(OPENID, CARDID)
        assert isinstance(res, dict)
        assert res['errcode'] == 0
示例#8
0
 def test_invalid_mediaid_error(self):
     appid = WECHAT.get('JSAPI', {}).get('appID')
     appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
     data = media_download('invalid_mediaid', appid=appid, secret=appsecret)
     assert isinstance(data, requests.Response)
     assert data.status_code == 200
     # {"errcode": 40007, "errmsg": "invalid media_id hint: [CNRD70014e298]"}
     assert data.json()['errcode'] == 40007
示例#9
0
 def test_invalid_accesstoken_error(self):
     appid = WECHAT.get('JSAPI', {}).get('appID')
     appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
     data = media_download('media_id', appid=appid, secret=appsecret, token='invalid_accesstoken')
     assert isinstance(data, requests.Response)
     assert data.status_code == 200
     # {"errcode": 40001, "errmsg": "invalid credential, access_token is invalid or not latest hint: [9kOn80882vr45!]"}
     assert data.json()['errcode'] == 40001
示例#10
0
 def test_invalid_mediaid_error(self):
     appid = WECHAT.get('JSAPI', {}).get('appID')
     appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
     data = media_download('invalid_mediaid', appid=appid, secret=appsecret)
     assert isinstance(data, requests.Response)
     assert data.status_code == 200
     # {"errcode": 40007, "errmsg": "invalid media_id hint: [CNRD70014e298]"}
     assert data.json()['errcode'] == 40007
示例#11
0
 def test_downloadurl(self):
     appid = WECHAT.get('JSAPI', {}).get('appID')
     appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
     downloadurl = media_downloadurl('media_id',
                                     appid=appid,
                                     secret=appsecret,
                                     token='invalid_accesstoken')
     assert isinstance(downloadurl, basestring)
示例#12
0
    def test_get_users(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        user = User(appid=appid, secret=appsecret)
        users = user.get_users()
        assert isinstance(users, dict)

        user = get_all_users(appid=appid, secret=appsecret)
        assert user is None
示例#13
0
 def test_invalid_accesstoken_error(self):
     appid = WECHAT.get('JSAPI', {}).get('appID')
     appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
     data = media_download('media_id',
                           appid=appid,
                           secret=appsecret,
                           token='invalid_accesstoken')
     assert isinstance(data, requests.Response)
     assert data.status_code == 200
     # {"errcode": 40001, "errmsg": "invalid credential, access_token is invalid or not latest hint: [9kOn80882vr45!]"}
     assert data.json()['errcode'] == 40001
示例#14
0
    def test_get_miniapp_extraData(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        membercard = MemberCard(appid=appid, secret=appsecret)
        data = membercard.get_miniapp_extraData(MEMBER_CARD_ID, 'test')
        assert isinstance(data, dict)
        assert data.get('encrypt_card_id', '')

        data = get_miniapp_extraData(MEMBER_CARD_ID, 'test', appid=appid, secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('encrypt_card_id', '')
示例#15
0
    def test_msg_sec_check(self):
        appid = WECHAT.get('WXA', {}).get('appID')
        appsecret = WECHAT.get('WXA', {}).get('appsecret')
        # media_file = open(IMAGE_PATH, 'rb')
        security = Security(appid=appid, secret=appsecret)
        data = security.msg_sec_check(CONTENT)
        assert isinstance(data, dict)
        assert data.get('errcode') == 87014

        data = msg_sec_check(CONTENT, appid=appid, secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('errcode') == 87014
示例#16
0
    def test_update_remark(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        user = User(appid=appid, secret=appsecret)
        data = user.update_remark(OPENID, '0123456789' * 2)
        assert isinstance(data, dict)
        assert data['errcode'] == 0

        data = update_remark(OPENID, '0123456789' * 4, appid=appid, secret=appsecret)
        assert isinstance(data, dict)
        assert data['errcode'] == 0
示例#17
0
    def test_batchget_user_info(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        infos = batchget_user_info(users=[
            {
                'openid': OPENID,
                'lang': 'zh_CN',
            },
        ], appid=appid, secret=appsecret)
        assert isinstance(infos, dict)
        assert isinstance(infos['user_info_list'], list)
示例#18
0
    def test_media_upload_download(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
        # media_file = open(IMAGE_PATH, 'rb')
        data = media_upload(media_file=None, media_file_path=IMAGE_PATH, appid=appid, secret=appsecret)
        # {u'media_id': u'KptzZFv35-iSWE6cgmsQpaeqw986IjcFlqumgm_IEkP3-8-wyMDJNw12H4b4RPVP', u'created_at': 1503983273, u'type': u'image'}
        assert isinstance(data, dict)
        assert data.get('media_id', '')

        media_id = data.get('media_id', '')
        data = media_download(media_id, appid=appid, secret=appsecret)
        assert isinstance(data, requests.Response)
        assert data.status_code == 200
示例#19
0
    def test_media(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
        media_file = open(IMAGE_PATH, 'rb')
        media = Media(appid=appid, secret=appsecret)
        data = media.upload(media_file=media_file)
        # {u'media_id': u'KptzZFv35-iSWE6cgmsQpaeqw986IjcFlqumgm_IEkP3-8-wyMDJNw12H4b4RPVP', u'created_at': 1503983273, u'type': u'image'}
        assert isinstance(data, dict)
        assert data.get('media_id', '')

        media_id = data.get('media_id', '')
        data = media.download(media_id, appid=appid, secret=appsecret)
        assert isinstance(data, requests.Response)
        assert data.status_code == 200
示例#20
0
    def test_get_wxa_code(self):
        appid = WECHAT.get('WXA', {}).get('appID')
        appsecret = WECHAT.get('WXA', {}).get('appsecret')
        wxaqr = WxaQRCode(appid=appid, secret=appsecret)
        data = wxaqr.get_wxa_code(path='pages/index/index',
                                  res_to_base64=False)
        assert isinstance(data, requests.Response)
        assert data.status_code == 200

        b64 = get_wxa_code(path='pages/index/index',
                           appid=appid,
                           secret=appsecret)
        assert isinstance(b64, basestring)
        assert b64.startswith('data:image/png;base64,')
示例#21
0
    def test_get_current_selfmenu_info(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        menu = Menu(appid=appid, secret=appsecret)
        menu.create_menu(MENUS)

        menus1 = menu.get_current_selfmenu_info()
        assert isinstance(menus1, dict)

        menus2 = get_current_selfmenu_info(appid=appid, secret=appsecret)
        assert isinstance(menus1, dict)

        assert menus1 == menus2
示例#22
0
    def test_del_menu(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        menu = Menu(appid=appid, secret=appsecret)
        menu1 = menu.delete_menu()
        assert isinstance(menu1, dict)
        assert menu1['errcode'] == 0
        assert menu1['errmsg'] == 'ok'

        menu2 = delete_menu(appid=appid, secret=appsecret)
        assert isinstance(menu2, dict)
        assert menu2['errcode'] == 0
        assert menu2['errmsg'] == 'ok'
示例#23
0
    def test_token_mem(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        token = ComponentToken(appid=appid, secret=appsecret)
        access_token1 = token.component_access_token(component_verify_ticket=COMPONENT_VERIFY_TICKET)
        assert isinstance(access_token1, basestring)

        access_token2 = component_access_token(appid=appid, secret=appsecret, component_verify_ticket=COMPONENT_VERIFY_TICKET)
        assert isinstance(access_token2, basestring)

        access_token3 = final_component_access_token(cls=token, appid=appid, secret=appsecret, component_verify_ticket=COMPONENT_VERIFY_TICKET)
        assert isinstance(access_token3, basestring)

        assert access_token1 == access_token3 != access_token2
示例#24
0
    def test_img_sec_check(self):
        appid = WECHAT.get('WXA', {}).get('appID')
        appsecret = WECHAT.get('WXA', {}).get('appsecret')
        media_file = open(IMAGE_PATH, 'rb')
        security = Security(appid=appid, secret=appsecret)
        data = security.img_sec_check(media_file=media_file)
        assert isinstance(data, dict)
        assert data.get('errcode') == 0

        data = img_sec_check(media_file=None,
                             media_file_path=IMAGE_PATH,
                             appid=appid,
                             secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('errcode') == 0
示例#25
0
    def test_cv_aicrop(self):
        appid = WECHAT.get('WXA', {}).get('appID')
        appsecret = WECHAT.get('WXA', {}).get('appsecret')
        media_file = open(IMAGE_PATH, 'rb')
        cv = CV(appid=appid, secret=appsecret)
        data = cv.aicrop(img_file=media_file)
        assert isinstance(data, dict)
        assert data.get('errcode') == 0

        data = cv_aicrop(img_file=None,
                         img_file_path=IMAGE_PATH,
                         appid=appid,
                         secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('errcode') == 0
示例#26
0
    def test_media_uploadimg(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
        media_file = open(IMAGE_PATH, 'rb')
        media = Media(appid=appid, secret=appsecret)
        data = media.uploadimg(media_file=media_file)
        # {"url":  "http://mmbiz.qpic.cn/mmbiz/gLO17UPS6FS2xsypf378iaNhWacZ1G1UplZYWEYfwvuU6Ont96b1roYs CNFwaRrSaKTPCUdBK9DgEHicsKwWCBRQ/0"}
        assert isinstance(data, dict)
        assert data.get('url', '')

        data2 = media_uploadimg(media_file_path=IMAGE_PATH, appid=appid, secret=appsecret, forcard=True)
        assert isinstance(data2, dict)
        assert data2.get('url', '')

        assert data.get('url', '') == data2.get('url', '')
示例#27
0
    def test_get_activate_url(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        membercard = MemberCard(appid=appid, secret=appsecret)
        data = membercard.get_activate_url(MEMBER_CARD_ID, 'test')
        # {u'errcode': 0,
        #  u'errmsg': u'ok',
        #  u'url': u'https://mp.weixin.qq.com/bizmall/activatemembercard?action=preshow&&encrypt_card_id=encrypt_card_id&outer_str=outer_str&biz=biz#wechat_redirect'}
        assert isinstance(data, dict)
        assert data.get('url', '')

        data = get_activate_url(MEMBER_CARD_ID, 'test', appid=appid, secret=appsecret)
        assert isinstance(data, dict)
        assert data.get('url', '')
示例#28
0
    def test_tags(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        user = User(appid=appid, secret=appsecret)
        data = user.tags_create('0123456789' * 2)
        assert isinstance(data, dict)
        assert isinstance(data['tag'], dict)
        tagid = data['tag']['id']

        data = user.members_batchtagging(tagid, [OPENID])
        assert isinstance(data, dict)
        assert data['errcode'] == 0

        data = user.tags_getidlist(OPENID)
        assert isinstance(data, dict)
        assert data['tagid_list'] is not None

        data = user.members_batchuntagging(tagid, [OPENID])
        assert isinstance(data, dict)
        assert data['errcode'] == 0

        tags = user.tags_get()
        assert isinstance(tags, dict)
        assert isinstance(tags['tags'], list)

        for tag in tags['tags']:
            tagid = tag.get('id', '')

            # 45058	不能修改0/1/2这三个系统默认保留的标签
            if tagid in [0, 1, 2]:
                continue

            # 更新标签
            data = user.tags_update(tagid, '0123456789' * 4)
            assert isinstance(data, dict)
            assert data['errcode'] == 0

            users = user.get_tag_users(tagid)
            assert isinstance(users, dict)
            assert users['count'] == 0

            # 删除标签
            data = user.tags_delete(tagid)
            assert isinstance(data, dict)
            assert data['errcode'] == 0
示例#29
0
    def test_token_mem(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        token = Token(appid=appid, secret=appsecret)
        access_token1 = token.access_token()
        assert isinstance(access_token1, basestring)

        access_token2 = access_token(appid=appid, secret=appsecret)
        assert isinstance(access_token2, basestring)

        access_token3 = final_access_token(cls=token,
                                           appid=appid,
                                           secret=appsecret)
        assert isinstance(access_token3, basestring)

        assert access_token1 == access_token3 != access_token2
示例#30
0
    def test_token_redis(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        r = redis.StrictRedisExtensions(host='localhost', port=6379, db=0)
        storage = RedisStorage(r)

        token = ComponentToken(appid=appid, secret=appsecret, storage=storage)
        access_token1 = token.component_access_token(component_verify_ticket=COMPONENT_VERIFY_TICKET)
        assert isinstance(access_token1, basestring)

        access_token2 = component_access_token(appid=appid, secret=appsecret, component_verify_ticket=COMPONENT_VERIFY_TICKET, storage=storage)
        assert isinstance(access_token2, basestring)

        access_token3 = final_component_access_token(cls=token, appid=appid, secret=appsecret, component_verify_ticket=COMPONENT_VERIFY_TICKET, storage=storage)
        assert isinstance(access_token3, basestring)

        assert access_token1 == access_token3 == access_token2
示例#31
0
    def test_get_blacks(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        user = User(appid=appid, secret=appsecret)
        data = user.mambers_batchblacklist([OPENID])
        assert isinstance(data, dict)
        assert data['errcode'] == 0

        users = user.get_blacks()
        assert isinstance(users, dict)

        data = get_all_blacks(appid=appid, secret=appsecret)
        assert data is None

        data = user.mambers_batchunblacklist([OPENID])
        assert isinstance(data, dict)
        assert data['errcode'] == 0
示例#32
0
    def test_media_uploadimg(self):
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
        media_file = open(IMAGE_PATH, 'rb')
        media = Media(appid=appid, secret=appsecret)
        data = media.uploadimg(media_file=media_file)
        # {"url":  "http://mmbiz.qpic.cn/mmbiz/gLO17UPS6FS2xsypf378iaNhWacZ1G1UplZYWEYfwvuU6Ont96b1roYs CNFwaRrSaKTPCUdBK9DgEHicsKwWCBRQ/0"}
        assert isinstance(data, dict)
        assert data.get('url', '')

        data2 = media_uploadimg(media_file_path=IMAGE_PATH,
                                appid=appid,
                                secret=appsecret,
                                forcard=True)
        assert isinstance(data2, dict)
        assert data2.get('url', '')

        assert data.get('url', '') == data2.get('url', '')
示例#33
0
    def test_component_ticket_mem(self):
        token = WECHAT.get('JSAPI', {}).get('token')
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
        encodingaeskey = WECHAT.get('JSAPI', {}).get('encodingaeskey')
        encrypt = 'ghzY0SkCfJlD/dKofrErxS2jaQCfNWWOkzque5y2jCZ+gn+Gv1WeDoKBh+A2RgasuU+B8ZiIl21t89XGZaGnsJ2xFD0rpBqkzmIg2GJslaDbjVJGxPd1kLjOPotbEgAgSqc2b9L3qr/gVq2yWLQrRmHWQndJ19MDhTr95jAL1NF98AkUdVwOlm6NPoAt/CPe82jQzGqBf6IxoupSofeP/Z3fP3itgSOu6VaKoD6mP6AijsdK/qsMxhSOJImTgaXNBGllvgtdTFA7CIqAbp4J/wuVtMlARX1oN3YCPCnJnHXatxZ2VjHINVZmUVSPdoBCw2telFEGJF1RSJTpq5bl/x9+440j0nOT6DF1t7AJLkoM9zUivj1OhrFY3U6ivTFwqbc0jpL4iCHswkaM44CEEeOwbS4tFSkYQI3cy9dtBBH0b23eJbJStwniUa321I394yS2sfu76TvZkM6ZpCjl8Q=='
        msg_signature = '5a9fba8c2a9a3c1e7356ded1b7d4b6df650a902f'
        timestamp = '1522391275'
        nonce = '720781927'
        ticket = 'ticket@@@9xVhCN6TsWYK8fu7hJqriI2B3aJckd-1epTmK-9TYL1bHfUcdR-JKvIDK9VvqF_id_0P7M2nn3WT-_7T_FxcQA'

        component_ticket = ComponentTicket(appid=appid, secret=appsecret, token=token, encodingaeskey=encodingaeskey, storage=None)
        component_ticket.set_component_verify_ticket(post_data=None, encrypt=encrypt, msg_signature=msg_signature, timestamp=timestamp, nonce=nonce)
        ticket1 = component_ticket.get_component_verify_ticket()
        assert isinstance(ticket1, basestring)
        assert ticket == ticket1

        set_component_verify_ticket(appid=appid, secret=appsecret, token=token, encodingaeskey=encodingaeskey, post_data=None, encrypt=encrypt, msg_signature=msg_signature, timestamp=timestamp, nonce=nonce, storage=None)
        ticket2 = get_component_verify_ticket(appid=appid, secret=appsecret, token=token, encodingaeskey=encodingaeskey, storage=None)
        assert ticket == ticket2
示例#34
0
    def test_create_nenu(self):
        """
        {u'errcode': 0, u'errmsg': u'ok'}
        {u'errcode': 40018, u'errmsg': u'invalid button name size hint: [2gMLZa0881vr29]'}
        {u'errcode': 40019, u'errmsg': u'invalid button key size hint: [pjPYTA0402vr32]'}
        {u'errcode': 44002, u'errmsg': u'empty post data hint: [pr1Z30406vr21]'}
        """
        appid = WECHAT.get('JSAPI', {}).get('appID')
        appsecret = WECHAT.get('JSAPI', {}).get('appsecret')

        menu = Menu(appid=appid, secret=appsecret)
        menu1 = menu.create_menu(MENUS)
        assert isinstance(menu1, dict)
        assert menu1['errcode'] == 0
        assert menu1['errmsg'] == 'ok'

        menu2 = create_menu(MENUS, appid=appid, secret=appsecret)
        assert isinstance(menu2, dict)
        assert menu2['errcode'] == 0
        assert menu2['errmsg'] == 'ok'
示例#35
0
 def test_downloadurl(self):
     appid = WECHAT.get('JSAPI', {}).get('appID')
     appsecret = WECHAT.get('JSAPI', {}).get('appsecret')
     downloadurl = media_downloadurl('media_id', appid=appid, secret=appsecret, token='invalid_accesstoken')
     assert isinstance(downloadurl, basestring)