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


Python http_client.METHOD_NOT_ALLOWED属性代码示例

本文整理汇总了Python中six.moves.http_client.METHOD_NOT_ALLOWED属性的典型用法代码示例。如果您正苦于以下问题:Python http_client.METHOD_NOT_ALLOWED属性的具体用法?Python http_client.METHOD_NOT_ALLOWED怎么用?Python http_client.METHOD_NOT_ALLOWED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在six.moves.http_client的用法示例。


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

示例1: test_delete_and_update_notification

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def test_delete_and_update_notification(self, method, mock_client):
        url = '/v1/notifications/%s' % uuidsentinel.fake_notification
        fake_req = fakes.HTTPRequest.blank(url, use_admin_context=True)
        fake_req.headers['Content-Type'] = 'application/json'
        fake_req.method = method
        resp = fake_req.get_response(self.app)
        self.assertEqual(http.METHOD_NOT_ALLOWED, resp.status_code) 
开发者ID:openstack,项目名称:masakari,代码行数:9,代码来源:test_notifications.py

示例2: test_create_not_allowed_http_method

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def test_create_not_allowed_http_method(self, method):
        """Wrong HTTP method"""
        body = {"vnfdId": uuidsentinel.vnfd_id}
        req = fake_request.HTTPRequest.blank('/vnf_instances')
        req.body = jsonutils.dump_as_bytes(body)
        req.headers['Content-Type'] = 'application/json'
        req.method = method
        resp = req.get_response(self.app)
        self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:11,代码来源:test_controller.py

示例3: test_instantiate_invalid_http_method

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def test_instantiate_invalid_http_method(self, method):
        # Wrong HTTP method
        body = fakes.get_vnf_instantiation_request_body()
        req = fake_request.HTTPRequest.blank(
            '/vnf_instances/29c770a3-02bc-4dfc-b4be-eb173ac00567/instantiate')
        req.body = jsonutils.dump_as_bytes(body)
        req.headers['Content-Type'] = 'application/json'
        req.method = method
        resp = req.get_response(self.app)
        self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:12,代码来源:test_controller.py

示例4: test_show_invalid_http_method

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def test_show_invalid_http_method(self, http_method):
        req = fake_request.HTTPRequest.blank(
            '/vnf_instances/%s' % constants.UUID)
        req.headers['Content-Type'] = 'application/json'
        req.method = http_method

        resp = req.get_response(self.app)
        self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:10,代码来源:test_controller.py

示例5: test_terminate_invalid_http_method

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def test_terminate_invalid_http_method(self, method):
        # Wrong HTTP method
        body = {'terminationType': 'GRACEFUL',
                'gracefulTerminationTimeout': 10}
        req = fake_request.HTTPRequest.blank(
            '/vnf_instances/%s/terminate' % uuidsentinel.vnf_instance_id)
        req.body = jsonutils.dump_as_bytes(body)
        req.headers['Content-Type'] = 'application/json'
        req.method = method
        resp = req.get_response(self.app)
        self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:13,代码来源:test_controller.py

示例6: test_heal_invalid_http_method

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def test_heal_invalid_http_method(self, method):
        body = {}
        req = fake_request.HTTPRequest.blank(
            '/vnf_instances/%s/heal' % uuidsentinel.vnf_instance_id)
        req.body = jsonutils.dump_as_bytes(body)
        req.headers['Content-Type'] = 'application/json'
        req.method = method

        resp = req.get_response(self.app)

        self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:13,代码来源:test_controller.py

示例7: _do_revoke

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import METHOD_NOT_ALLOWED [as 别名]
def _do_revoke(self, http, token):
        """Revokes this credential and deletes the stored copy (if it exists).

        Args:
            http: an object to be used to make HTTP requests.
            token: A string used as the token to be revoked. Can be either an
                   access_token or refresh_token.

        Raises:
            TokenRevokeError: If the revoke request does not return with a
                              200 OK.
        """
        logger.info('Revoking token')
        query_params = {'token': token}
        token_revoke_uri = _helpers.update_query_params(
            self.revoke_uri, query_params)
        resp, content = transport.request(http, token_revoke_uri)
        if resp.status == http_client.METHOD_NOT_ALLOWED:
            body = urllib.parse.urlencode(query_params)
            resp, content = transport.request(http, token_revoke_uri,
                                              method='POST', body=body)
        if resp.status == http_client.OK:
            self.invalid = True
        else:
            error_msg = 'Invalid response {0}.'.format(resp.status)
            try:
                d = json.loads(_helpers._from_bytes(content))
                if 'error' in d:
                    error_msg = d['error']
            except (TypeError, ValueError):
                pass
            raise TokenRevokeError(error_msg)

        if self.store:
            self.store.delete() 
开发者ID:haynieresearch,项目名称:jarvis,代码行数:37,代码来源:client.py


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