def test_get_user_list_failure(self): """Test get user list failure""" access_token = 'access_token' result = WechatAPI.get_user_list(access_token) self.assertIn('errmsg', result) self.assertIn('requrl', result)
def test_get_user_list_next_openid(self, mock_data): """Test get user list with next openid.""" access_token = 'access_token' openid = 'openid' mock_data.return_value = { 'user_info_list': [ { 'subscribe': 1, 'openid': 'otvxTs4dckWG7imySrJd6jSi0CWE', 'nickname': 'iWithery', 'sex': 1, 'language': 'zh_CN', 'city': 'Jieyang', 'province': 'Guangdong', 'country': 'China', 'headimgurl': ('http://wx.qlogo.cn/mmopen/xbIQx1GRqdvyqkMM' 'hEaGOX802l1CyqMJNgUzKP8MeAeHFicRDSnZH7FY4X' 'B7p8XHXIf6uJA2SCunTPic' 'GKezDC4saKISzRj3nz/0'), 'subscribe_time': 1434093047, 'unionid': 'oR5GjjgEhCMJFyzaVZdrxZ2zRRF4', 'remark': '', 'groupid': 0 }, { 'subscribe': 0, 'openid': 'otvxTs_JZ6SEiP0imdhpi50fuSZg', 'unionid': 'oR5GjjjrbqBZbrnPwwmSxFukE41U' } ] } resp = WechatAPI.get_user_list(access_token, next_openid=openid) self.assertEqual(len(resp['user_info_list']), 2)