def test_get_user_info_failure(self): """Test get user info failure""" access_token, openid = 'access_token', 'openid' result = WechatAPI.get_user_info(access_token, openid) self.assertIn('errmsg', result) self.assertIn('requrl', result)
def test_get_user_info(self, mock_data): """Test get user basic info.""" access_token = 'access_token' openid = 'o6_bmjrPTlm6_2sgVt7hMZOPfL2M' mock_data.return_value = { 'subscribe': 1, 'openid': openid, 'nickname': 'Band', 'sex': 1, 'language': 'zh_CN', 'city': '广州', 'province': '广东', 'country': '中国', 'headimgurl': ('http://wx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6ia' 'FqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbE' 'RQQ4eMsv84eavHiaiceqxibJxCfHe/0'), 'subscribe_time': 1382694957, 'unionid': 'o6_bmasdasdsad6_2sgVt7hMZOPfL', 'remark': '', 'groupid': 0 } resp = WechatAPI.get_user_info(access_token, openid) self.assertEqual(resp.get('openid'), openid)