當前位置: 首頁>>代碼示例>>Python>>正文


Python Fitbit.user_profile_get方法代碼示例

本文整理匯總了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)
開發者ID:GregKinne,項目名稱:python-fitbit,代碼行數:20,代碼來源:test_exceptions.py

示例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()
開發者ID:GregKinne,項目名稱:python-fitbit,代碼行數:21,代碼來源:test_exceptions.py

示例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())
開發者ID:jontrainor,項目名稱:onpeakFitbitApp,代碼行數:7,代碼來源:fit.py


注:本文中的fitbit.Fitbit.user_profile_get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。