本文整理汇总了Python中fitbit.Fitbit.user_profile_get方法的典型用法代码示例。如果您正苦于以下问题:Python Fitbit.user_profile_get方法的具体用法?Python Fitbit.user_profile_get怎么用?Python Fitbit.user_profile_get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fitbit.Fitbit
的用法示例。
在下文中一共展示了Fitbit.user_profile_get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_too_many_requests
# 需要导入模块: from fitbit import Fitbit [as 别名]
# 或者: from fitbit.Fitbit import user_profile_get [as 别名]
def test_too_many_requests(self):
"""
Tests the 429 response, given in case of exceeding the rate limit
"""
r = mock.Mock(spec=requests.Response)
r.content = b"{'normal': 'resource'}"
r.headers = {'Retry-After': '10'}
f = Fitbit(**self.client_kwargs)
f.client._request = lambda *args, **kwargs: r
r.status_code = 429
try:
f.user_profile_get()
self.assertEqual(True, False) # Won't run if an exception's raised
except exceptions.HTTPTooManyRequests:
e = sys.exc_info()[1]
self.assertEqual(e.retry_after_secs, 10)
示例2: test_response_ok
# 需要导入模块: from fitbit import Fitbit [as 别名]
# 或者: from fitbit.Fitbit import user_profile_get [as 别名]
def test_response_ok(self):
"""
This mocks a pretty normal resource, that the request was authenticated,
and data was returned. This test should just run and not raise any
exceptions
"""
r = mock.Mock(spec=requests.Response)
r.status_code = 200
r.content = b'{"normal": "resource"}'
f = Fitbit(**self.client_kwargs)
f.client._request = lambda *args, **kwargs: r
f.user_profile_get()
r.status_code = 202
f.user_profile_get()
r.status_code = 204
f.user_profile_get()
示例3: index
# 需要导入模块: from fitbit import Fitbit [as 别名]
# 或者: from fitbit.Fitbit import user_profile_get [as 别名]
def index():
if 'fitbit_access_token' not in session:
return redirect(url_for('login'))
client = Fitbit(CONSUMER_KEY, CONSUMER_SECRET, resource_owner_key=session['fitbit_access_token']['oauth_token'], resource_owner_secret=session['fitbit_access_token']['oauth_token_secret'])
return str(client.user_profile_get())