MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / test_grant_token

Method test_grant_token

tests/test_basic.py:77–89  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

75 self.assertFalse(wechat.check_signature(signature=signature, timestamp=timestamp+'2', nonce=nonce))
76
77 def test_grant_token(self):
78 # 测试无 appid 和 appsecret 初始化
79 wechat = WechatBasic()
80 with self.assertRaises(NeedParamError):
81 wechat.grant_token()
82
83 # 测试有 appid 和 appsecret 初始化(覆盖已有 access_token,默认override=True即覆盖)
84 wechat = WechatBasic(appid=self.appid, appsecret=self.appsecret)
85 with HTTMock(wechat_api_mock):
86 resp = wechat.grant_token()
87 self.assertEqual(resp['access_token'], self.fixtures_access_token)
88 self.assertEqual(resp['expires_in'], 7200)
89 self.assertEqual(wechat.conf.access_token, self.fixtures_access_token)
90
91 def test_grant_jsapi_ticket(self):
92 # 测试无 appid 和 appsecret 初始化

Callers

nothing calls this directly

Calls 2

grant_tokenMethod · 0.95
WechatBasicClass · 0.90

Tested by

no test coverage detected