當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。