本文整理汇总了Python中six.moves.http_client.ACCEPTED属性的典型用法代码示例。如果您正苦于以下问题:Python http_client.ACCEPTED属性的具体用法?Python http_client.ACCEPTED怎么用?Python http_client.ACCEPTED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类six.moves.http_client
的用法示例。
在下文中一共展示了http_client.ACCEPTED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _deny_access
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def _deny_access(self, req, id, body):
"""Remove share access rule."""
context = req.environ['manila.context']
access_id = body.get(
'deny_access', body.get('os-deny_access'))['access_id']
try:
access = self.share_api.access_get(context, access_id)
if access.share_id != id:
raise exception.NotFound()
share = self.share_api.get(context, id)
except exception.NotFound as error:
raise webob.exc.HTTPNotFound(explanation=six.text_type(error))
self.share_api.deny_access(context, share, access)
return webob.Response(status_int=http_client.ACCEPTED)
示例2: _delete
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def _delete(self, req, type_id, id):
"""Deletes an existing extra spec."""
context = req.environ['manila.context']
if id in share_types.get_required_extra_specs():
msg = _("Extra spec '%s' can't be deleted.") % id
raise webob.exc.HTTPForbidden(explanation=msg)
try:
db.share_type_extra_specs_delete(context, type_id, id)
except exception.ShareTypeExtraSpecsNotFound as error:
raise webob.exc.HTTPNotFound(explanation=error.msg)
notifier_info = dict(type_id=type_id, id=id)
notifier = rpc.get_notifier('shareTypeExtraSpecs')
notifier.info(context, 'share_type_extra_specs.delete', notifier_info)
return webob.Response(status_int=http_client.ACCEPTED)
示例3: delete
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def delete(self, req, id):
"""Delete specified share server."""
context = req.environ['manila.context']
try:
share_server = db_api.share_server_get(context, id)
except exception.ShareServerNotFound as e:
raise exc.HTTPNotFound(explanation=e.msg)
allowed_statuses = [constants.STATUS_ERROR, constants.STATUS_ACTIVE]
if share_server['status'] not in allowed_statuses:
data = {
'status': share_server['status'],
'allowed_statuses': allowed_statuses,
}
msg = _("Share server's actual status is %(status)s, allowed "
"statuses for deletion are %(allowed_statuses)s.") % (data)
raise exc.HTTPForbidden(explanation=msg)
LOG.debug("Deleting share server with id: %s.", id)
try:
self.share_api.delete_share_server(context, share_server)
except exception.ShareServerInUse as e:
raise exc.HTTPConflict(explanation=e.msg)
return webob.Response(status_int=http_client.ACCEPTED)
示例4: _delete
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def _delete(self, req, id):
"""Deletes an existing share type."""
context = req.environ['manila.context']
try:
share_type = share_types.get_share_type(context, id)
share_types.destroy(context, share_type['id'])
self._notify_share_type_info(
context, 'share_type.delete', share_type)
except exception.ShareTypeInUse as err:
notifier_err = dict(id=id, error_message=six.text_type(err))
self._notify_share_type_error(context, 'share_type.delete',
notifier_err)
msg = 'Target share type is still in use.'
raise webob.exc.HTTPBadRequest(explanation=msg)
except exception.NotFound as err:
notifier_err = dict(id=id, error_message=six.text_type(err))
self._notify_share_type_error(context, 'share_type.delete',
notifier_err)
raise webob.exc.HTTPNotFound()
return webob.Response(status_int=http_client.ACCEPTED)
示例5: delete
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def delete(self, req, id):
"""Delete a replica."""
context = req.environ['manila.context']
try:
replica = db.share_replica_get(context, id)
except exception.ShareReplicaNotFound:
msg = _("No replica exists with ID %s.")
raise exc.HTTPNotFound(explanation=msg % id)
try:
self.share_api.delete_share_replica(context, replica)
except exception.ReplicationException as e:
raise exc.HTTPBadRequest(explanation=six.text_type(e))
return webob.Response(status_int=http_client.ACCEPTED)
示例6: _delete
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def _delete(self, req, id):
context = req.environ['manila.context']
params = parse.parse_qs(req.environ.get('QUERY_STRING', ''))
user_id = params.get('user_id', [None])[0]
share_type = params.get('share_type', [None])[0]
self._validate_user_id_and_share_type_args(user_id, share_type)
try:
db.authorize_project_context(context, id)
if user_id:
QUOTAS.destroy_all_by_project_and_user(context, id, user_id)
elif share_type:
share_type_id = self._get_share_type_id(context, share_type)
QUOTAS.destroy_all_by_project_and_share_type(
context, id, share_type_id)
else:
QUOTAS.destroy_all_by_project(context, id)
return webob.Response(status_int=http_client.ACCEPTED)
except exception.NotAuthorized:
raise webob.exc.HTTPForbidden()
示例7: test_create_success_with_201_response_code
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_create_success_with_201_response_code(
self, mock_client, mock_create):
body = {
"notification": {
"hostname": "fake_host",
"payload": {
"instance_uuid": uuidsentinel.instance_uuid,
"vir_domain_event": "STOPPED_FAILED",
"event": "LIFECYCLE"
},
"type": "VM",
"generated_time": NOW
}
}
fake_req = self.req
fake_req.headers['Content-Type'] = 'application/json'
fake_req.method = 'POST'
fake_req.body = jsonutils.dump_as_bytes(body)
resp = fake_req.get_response(self.app)
self.assertEqual(http.ACCEPTED, resp.status_code)
示例8: test_resource_headers_py2_are_utf8
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_resource_headers_py2_are_utf8(self):
resp = webob.Response(status_int=http.ACCEPTED)
resp.headers['x-header1'] = 1
resp.headers['x-header2'] = u'header2'
resp.headers['x-header3'] = u'header3'
class Controller(object):
def index(self, req):
return resp
req = webob.Request.blank('/tests')
app = fakes.TestRouter(Controller())
response = req.get_response(app)
if six.PY2:
for val in response.headers.values():
# All headers must be utf8
self.assertThat(val, matchers.EncodedByUTF8())
self.assertEqual(b'1', response.headers['x-header1'])
self.assertEqual(b'header2', response.headers['x-header2'])
self.assertEqual(b'header3', response.headers['x-header3'])
else:
self.assertEqual('1', response.headers['x-header1'])
self.assertEqual(u'header2', response.headers['x-header2'])
self.assertEqual(u'header3', response.headers['x-header3'])
示例9: test_upload_vnf_package_content
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_upload_vnf_package_content(self, mock_vnf_pack_save,
mock_vnf_by_id,
mock_upload_vnf_package_content,
mock_glance_store):
updates = {'onboarding_state': 'CREATED',
'operational_state': 'DISABLED'}
vnf_package_dict = fakes.fake_vnf_package(updates)
vnf_package_obj = objects.VnfPackage(**vnf_package_dict)
mock_vnf_by_id.return_value = vnf_package_obj
mock_vnf_pack_save.return_value = vnf_package_obj
mock_glance_store.return_value = 'location', 0, 'checksum',\
'multihash', 'loc_meta'
req = fake_request.HTTPRequest.blank(
'/vnf_packages/%s/package_content'
% constants.UUID)
req.headers['Content-Type'] = 'application/zip'
req.method = 'PUT'
req.body = jsonutils.dump_as_bytes(mock.mock_open())
resp = req.get_response(self.app)
mock_glance_store.assert_called()
self.assertEqual(http_client.ACCEPTED, resp.status_code)
示例10: test_upload_vnf_package_from_uri
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_upload_vnf_package_from_uri(self, mock_vnf_pack_save,
mock_vnf_by_id,
mock_upload_vnf_package_from_uri,
mock_url_open):
body = {"addressInformation": "http://localhost/test_data.zip"}
updates = {'onboarding_state': 'CREATED',
'operational_state': 'DISABLED'}
vnf_package_dict = fakes.fake_vnf_package(updates)
vnf_package_obj = objects.VnfPackage(**vnf_package_dict)
mock_vnf_by_id.return_value = vnf_package_obj
mock_vnf_pack_save.return_value = vnf_package_obj
req = fake_request.HTTPRequest.blank(
'/vnf_packages/%s/package_content/upload_from_uri'
% constants.UUID)
req.headers['Content-Type'] = 'application/json'
req.method = 'POST'
req.body = jsonutils.dump_as_bytes(body)
resp = req.get_response(self.app)
self.assertEqual(http_client.ACCEPTED, resp.status_code)
示例11: test_instantiate_with_deployment_flavour
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_instantiate_with_deployment_flavour(
self, mock_instantiate, mock_vnf_package_get_by_id,
mock_vnf_package_vnfd_get_by_id, mock_save,
mock_vnf_instance_get_by_id, mock_get_vim):
mock_vnf_instance_get_by_id.return_value =\
fakes.return_vnf_instance_model()
mock_vnf_package_vnfd_get_by_id.return_value = \
fakes.return_vnf_package_vnfd()
mock_vnf_package_get_by_id.return_value = \
fakes.return_vnf_package_with_deployment_flavour()
body = {"flavourId": "simple"}
req = fake_request.HTTPRequest.blank(
'/vnf_instances/%s/instantiate' % uuidsentinel.vnf_instance_id)
req.body = jsonutils.dump_as_bytes(body)
req.headers['Content-Type'] = 'application/json'
req.method = 'POST'
# Call Instantiate API
resp = req.get_response(self.app)
self.assertEqual(http_client.ACCEPTED, resp.status_code)
mock_instantiate.assert_called_once()
示例12: test_instantiate_with_instantiation_level
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_instantiate_with_instantiation_level(
self, mock_instantiate, mock_vnf_package_get_by_id,
mock_vnf_package_vnfd_get_by_id, mock_save,
mock_vnf_instance_get_by_id, mock_get_vim):
mock_vnf_instance_get_by_id.return_value =\
fakes.return_vnf_instance_model()
mock_vnf_package_vnfd_get_by_id.return_value = \
fakes.return_vnf_package_vnfd()
mock_vnf_package_get_by_id.return_value = \
fakes.return_vnf_package_with_deployment_flavour()
body = {"flavourId": "simple",
"instantiationLevelId": "instantiation_level_1"}
req = fake_request.HTTPRequest.blank(
'/vnf_instances/%s/instantiate' % uuidsentinel.vnf_instance_id)
req.body = jsonutils.dump_as_bytes(body)
req.headers['Content-Type'] = 'application/json'
req.method = 'POST'
# Call Instantiate API
resp = req.get_response(self.app)
self.assertEqual(http_client.ACCEPTED, resp.status_code)
mock_instantiate.assert_called_once()
示例13: test_heal
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_heal(self, body, mock_rpc_heal, mock_save,
mock_vnf_by_id):
vnf_instance_obj = fakes.return_vnf_instance(
fields.VnfInstanceState.INSTANTIATED)
mock_vnf_by_id.return_value = vnf_instance_obj
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 = 'POST'
resp = req.get_response(self.app)
self.assertEqual(http_client.ACCEPTED, resp.status_code)
mock_rpc_heal.assert_called_once()
示例14: test_operation_invoke_with_urlopen_accept_no_content__data
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_operation_invoke_with_urlopen_accept_no_content__data(self,
status_code):
"""
suds.client.Client web service operation invocation expecting output
data, and for which a corresponding urlopen call raises a HTTPError
with status code ACCEPTED or NO_CONTENT, should report this as a
TransportError.
"""
e = self.create_HTTPError(code=status_code)
transport = suds.transport.http.HttpTransport()
transport.urlopener = MockURLOpenerSaboteur(open_exception=e)
wsdl = testutils.wsdl('<xsd:element name="o" type="xsd:string"/>',
output="o", operation_name="f")
client = testutils.client_from_wsdl(wsdl, transport=transport)
pytest.raises(suds.transport.TransportError, client.service.f)
示例15: test_operation_invoke_with_urlopen_accept_no_content__no_data
# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import ACCEPTED [as 别名]
def test_operation_invoke_with_urlopen_accept_no_content__no_data(self,
status_code):
"""
suds.client.Client web service operation invocation expecting no output
data, and for which a corresponding urlopen call raises a HTTPError
with status code ACCEPTED or NO_CONTENT, should treat this as a
successful invocation.
"""
# We are not yet sure that the behaviour checked for in this test is
# actually desired. The test is only an 'educated guess' prepared to
# demonstrate a related problem in the original suds library
# implementation. The original implementation is definitely buggy as
# its web service operation invocation raises an AttributeError
# exception by attempting to access a non-existing 'None.message'
# attribute internally.
e = self.create_HTTPError(code=status_code)
transport = suds.transport.http.HttpTransport()
transport.urlopener = MockURLOpenerSaboteur(open_exception=e)
wsdl = testutils.wsdl('<xsd:element name="o" type="xsd:string"/>',
output="o", operation_name="f")
client = testutils.client_from_wsdl(wsdl, transport=transport)
assert client.service.f() is None