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


Python TokenHandler.from_string方法代碼示例

本文整理匯總了Python中website.tokens.TokenHandler.from_string方法的典型用法代碼示例。如果您正苦於以下問題:Python TokenHandler.from_string方法的具體用法?Python TokenHandler.from_string怎麽用?Python TokenHandler.from_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在website.tokens.TokenHandler的用法示例。


在下文中一共展示了TokenHandler.from_string方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_sanction_handler

# 需要導入模塊: from website.tokens import TokenHandler [as 別名]
# 或者: from website.tokens.TokenHandler import from_string [as 別名]
 def test_sanction_handler(self):
     if not self.kind:
         return
     approval_token = self.sanction.approval_state[self.user._id]['approval_token']
     handler = TokenHandler.from_string(approval_token)
     with mock_auth(self.user):
         with mock.patch('website.tokens.handlers.{0}_handler'.format(self.kind)) as mock_handler:
             handler.to_response()
             mock_handler.assert_called_with('approve', self.reg, self.reg.registered_from)
開發者ID:aaxelb,項目名稱:osf.io,代碼行數:11,代碼來源:test_tokens.py

示例2: test_sanction_handler_no_sanction

# 需要導入模塊: from website.tokens import TokenHandler [as 別名]
# 或者: from website.tokens.TokenHandler import from_string [as 別名]
 def test_sanction_handler_no_sanction(self):
     if not self.kind:
         return
     approval_token = self.sanction.approval_state[self.user._id]['approval_token']
     handler = TokenHandler.from_string(approval_token)
     self.Model.delete(self.sanction)
     with mock_auth(self.user):
         try:
             handler.to_response()
         except HTTPError as e:
             assert_equal(e.code, http.BAD_REQUEST)
             assert_equal(e.data['message_long'], NO_SANCTION_MSG.format(self.Model.DISPLAY_NAME))
開發者ID:aaxelb,項目名稱:osf.io,代碼行數:14,代碼來源:test_tokens.py

示例3: test_sanction_handler_sanction_rejected

# 需要導入模塊: from website.tokens import TokenHandler [as 別名]
# 或者: from website.tokens.TokenHandler import from_string [as 別名]
 def test_sanction_handler_sanction_rejected(self):
     if not self.kind:
         return
     approval_token = self.sanction.approval_state[self.user._id]['approval_token']
     handler = TokenHandler.from_string(approval_token)
     self.sanction.state = Sanction.REJECTED
     self.sanction.save()
     with mock_auth(self.user):
         try:
             handler.to_response()
         except HTTPError as e:
             assert_equal(e.code, http.GONE if self.kind in ['embargo', 'registration_approval'] else http.BAD_REQUEST)
             assert_equal(e.data['message_long'], REJECTED_MSG.format(self.sanction.DISPLAY_NAME))
開發者ID:aaxelb,項目名稱:osf.io,代碼行數:15,代碼來源:test_tokens.py

示例4: test_from_string

# 需要導入模塊: from website.tokens import TokenHandler [as 別名]
# 或者: from website.tokens.TokenHandler import from_string [as 別名]
 def test_from_string(self):
     token = TokenHandler.from_string(self.encoded_token)
     assert_equal(token.encoded_token, self.encoded_token)
     assert_equal(token.payload, self.payload)
開發者ID:aaxelb,項目名稱:osf.io,代碼行數:6,代碼來源:test_tokens.py


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