本文整理匯總了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())