本文整理汇总了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()