当前位置: 首页>>代码示例>>Python>>正文


Python tokens.TokenHandler类代码示例

本文整理汇总了Python中website.tokens.TokenHandler的典型用法代码示例。如果您正苦于以下问题:Python TokenHandler类的具体用法?Python TokenHandler怎么用?Python TokenHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TokenHandler类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sanction_handler

 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,代码行数:9,代码来源:test_tokens.py

示例2: test_sanction_handler_no_sanction

 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,代码行数:12,代码来源:test_tokens.py

示例3: test_token_process_with_valid_action

 def test_token_process_with_valid_action(self, mock_handler):
     self.payload['action'] = 'approve_registration_approval'
     token = TokenHandler.from_payload(self.payload)
     token.to_response()
     assert_true(
         mock_handler.called_with(
             'registration',
             'approve',
             self.payload,
             self.encoded_token
         )
     )
开发者ID:aaxelb,项目名称:osf.io,代码行数:12,代码来源:test_tokens.py

示例4: test_sanction_handler_sanction_rejected

 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,代码行数:13,代码来源:test_tokens.py

示例5: test_token_process_for_invalid_action_raises_TokenHandlerNotFound

 def test_token_process_for_invalid_action_raises_TokenHandlerNotFound(self):
     self.payload['action'] = 'not a handler'
     token = TokenHandler.from_payload(self.payload)
     with assert_raises(TokenHandlerNotFound):
         token.to_response()
开发者ID:aaxelb,项目名称:osf.io,代码行数:5,代码来源:test_tokens.py

示例6: test_from_payload

 def test_from_payload(self):
     token = TokenHandler.from_payload(self.payload)
     assert_equal(token.encoded_token, self.encoded_token)
     assert_equal(token.payload, self.payload)
开发者ID:aaxelb,项目名称:osf.io,代码行数:4,代码来源:test_tokens.py


注:本文中的website.tokens.TokenHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。