本文整理匯總了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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()