(self)
| 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 初始化 |
nothing calls this directly
no test coverage detected