-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathtest_renren.py
More file actions
26 lines (21 loc) · 868 Bytes
/
test_renren.py
File metadata and controls
26 lines (21 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# coding=utf-8
from unittest import TestCase
from chinaapi.renren.open import Client, App
from chinaapi.exceptions import ApiError
class RenRenTest(TestCase):
"""
注释部分的测试需填写app_key,app_secret,access_token
"""
def setUp(self):
app = App('app_key', 'app_secret') # 填上自己的app_key,app_secret
self.client = Client(app)
self.client.set_access_token('access_token') # 填上取得的access_token
self.uid = 334258249
# def test_users_get(self):
# r = self.client.user.get(userId=self.uid)
# self.assertEqual(self.uid, r.id)
def test_api_error(self):
self.client.token.access_token = ''
with self.assertRaises(ApiError) as cm:
self.client.user.get(userId=self.uid)
self.assertEqual(u'验证参数错误。', cm.exception.message)