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


Python http_client.CONFLICT属性代码示例

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


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

示例1: test_check_response_bad_stream

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_check_response_bad_stream(self, caplog, log_errors):
        iterable = [b'iter', b'lines']
        status_code = http_client.CONFLICT
        response = Response(status_code, iterable=iterable)
        if log_errors:
            log_type = logging.ERROR
        else:
            log_type = logging.DEBUG

        with pytest.raises(OsbsResponseException):
            if log_errors:
                check_response(response)
            else:
                check_response(response, log_level=log_type)

        logged = [(l.getMessage(), l.levelno) for l in caplog.records]
        assert len(logged) == 1
        assert logged[0][0] == '[{code}] {message}'.format(code=status_code,
                                                           message=b'iterlines')
        assert logged[0][1] == log_type 
开发者ID:containerbuildsystem,项目名称:osbs-client,代码行数:22,代码来源:test_core.py

示例2: test_check_response_bad_nostream

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_check_response_bad_nostream(self, caplog, log_errors):
        status_code = http_client.CONFLICT
        content = b'content'
        response = Response(status_code, content=content)
        if log_errors:
            log_type = logging.ERROR
        else:
            log_type = logging.DEBUG

        with pytest.raises(OsbsResponseException):
            if log_errors:
                check_response(response)
            else:
                check_response(response, log_level=log_type)

        logged = [(l.getMessage(), l.levelno) for l in caplog.records]
        assert len(logged) == 1
        assert logged[0][0] == '[{code}] {message}'.format(code=status_code,
                                                           message=content)
        assert logged[0][1] == log_type 
开发者ID:containerbuildsystem,项目名称:osbs-client,代码行数:22,代码来源:test_core.py

示例3: create_resource_quota

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def create_resource_quota(self, name, quota_json):
        """
        Prevent builds being scheduled and wait for running builds to finish.

        :return:
        """

        url = self._build_k8s_url("resourcequotas/")
        response = self._post(url, data=json.dumps(quota_json),
                              headers={"Content-Type": "application/json"})
        if response.status_code == http_client.CONFLICT:
            url = self._build_k8s_url("resourcequotas/%s" % name)
            response = self._put(url, data=json.dumps(quota_json),
                                 headers={"Content-Type": "application/json"})

        check_response(response)
        return response 
开发者ID:containerbuildsystem,项目名称:osbs-client,代码行数:19,代码来源:core.py

示例4: test_upload_from_file_failure

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_upload_from_file_failure(self):
        import requests

        from google.resumable_media import InvalidResponse
        from google.cloud import exceptions

        message = "Someone is already in this spot."
        response = requests.Response()
        response.status_code = http_client.CONFLICT
        response.request = requests.Request("POST", "http://example.com").prepare()
        side_effect = InvalidResponse(response, message)

        with self.assertRaises(exceptions.Conflict) as exc_info:
            self._upload_from_file_helper(side_effect=side_effect)

        self.assertIn(message, exc_info.exception.message)
        self.assertEqual(exc_info.exception.errors, []) 
开发者ID:googleapis,项目名称:python-storage,代码行数:19,代码来源:test_blob.py

示例5: test_instantiate_incorrect_task_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_instantiate_incorrect_task_state(self, mock_vnf_by_id):
        vnf_instance = fakes.return_vnf_instance_model(
            task_state=fields.VnfInstanceTaskState.INSTANTIATING)
        mock_vnf_by_id.return_value = vnf_instance

        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'

        resp = req.get_response(self.app)

        self.assertEqual(http_client.CONFLICT, resp.status_code)
        expected_msg = ("Vnf instance %s in task_state INSTANTIATING. Cannot "
                        "instantiate while the vnf instance is in this state.")
        self.assertEqual(expected_msg % uuidsentinel.vnf_instance_id,
            resp.json['conflictingRequest']['message']) 
开发者ID:openstack,项目名称:tacker,代码行数:21,代码来源:test_controller.py

示例6: test_terminate_incorrect_instantiation_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_terminate_incorrect_instantiation_state(self, mock_vnf_by_id):
        mock_vnf_by_id.return_value = fakes.return_vnf_instance()
        body = {"terminationType": "FORCEFUL"}
        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 = 'POST'

        resp = req.get_response(self.app)

        self.assertEqual(http_client.CONFLICT, resp.status_code)
        expected_msg = ("Vnf instance %s in instantiation_state "
                        "NOT_INSTANTIATED. Cannot terminate while the vnf "
                        "instance is in this state.")
        self.assertEqual(expected_msg % uuidsentinel.vnf_instance_id,
            resp.json['conflictingRequest']['message']) 
开发者ID:openstack,项目名称:tacker,代码行数:19,代码来源:test_controller.py

示例7: test_terminate_incorrect_task_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_terminate_incorrect_task_state(self, mock_vnf_by_id):
        vnf_instance = fakes.return_vnf_instance(
            instantiated_state=fields.VnfInstanceState.INSTANTIATED,
            task_state=fields.VnfInstanceTaskState.TERMINATING)
        mock_vnf_by_id.return_value = vnf_instance

        body = {"terminationType": "FORCEFUL"}
        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 = 'POST'

        resp = req.get_response(self.app)

        self.assertEqual(http_client.CONFLICT, resp.status_code)
        expected_msg = ("Vnf instance %s in task_state TERMINATING. Cannot "
                        "terminate while the vnf instance is in this state.")
        self.assertEqual(expected_msg % uuidsentinel.vnf_instance_id,
            resp.json['conflictingRequest']['message']) 
开发者ID:openstack,项目名称:tacker,代码行数:22,代码来源:test_controller.py

示例8: test_heal_incorrect_task_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_heal_incorrect_task_state(self, mock_vnf_by_id):
        vnf_instance_obj = fakes.return_vnf_instance(
            fields.VnfInstanceState.INSTANTIATED,
            task_state=fields.VnfInstanceTaskState.HEALING)
        mock_vnf_by_id.return_value = vnf_instance_obj

        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 = 'POST'

        resp = req.get_response(self.app)
        self.assertEqual(http_client.CONFLICT, resp.status_code)
        expected_msg = ("Vnf instance %s in task_state "
                       "HEALING. Cannot heal while the vnf instance "
                       "is in this state.")
        self.assertEqual(expected_msg % uuidsentinel.vnf_instance_id,
                resp.json['conflictingRequest']['message']) 
开发者ID:openstack,项目名称:tacker,代码行数:22,代码来源:test_controller.py

示例9: test_delete_with_incorrect_instantiation_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_delete_with_incorrect_instantiation_state(self, mock_vnf_by_id):
        req = fake_request.HTTPRequest.blank(
            '/vnf_instances/%s' % uuidsentinel.vnf_instance_id)
        req.method = 'DELETE'

        vnf_instance = fakes.return_vnf_instance(
            fields.VnfInstanceState.INSTANTIATED)
        mock_vnf_by_id.return_value = vnf_instance

        # Call delete API
        resp = req.get_response(self.app)

        self.assertEqual(http_client.CONFLICT, resp.status_code)
        expected_msg = ("Vnf instance %s in instantiation_state "
                       "INSTANTIATED. Cannot delete while the vnf instance "
                       "is in this state.")
        self.assertEqual(expected_msg % uuidsentinel.vnf_instance_id,
                resp.json['conflictingRequest']['message']) 
开发者ID:openstack,项目名称:tacker,代码行数:20,代码来源:test_controller.py

示例10: test_delete_with_incorrect_task_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_delete_with_incorrect_task_state(self, mock_vnf_by_id):
        req = fake_request.HTTPRequest.blank(
            '/vnf_instances/%s' % uuidsentinel.vnf_instance_id)
        req.method = 'DELETE'

        vnf_instance = fakes.return_vnf_instance(
            fields.VnfInstanceState.NOT_INSTANTIATED,
            task_state=fields.VnfInstanceTaskState.ERROR)
        mock_vnf_by_id.return_value = vnf_instance

        # Call delete API
        resp = req.get_response(self.app)

        self.assertEqual(http_client.CONFLICT, resp.status_code)
        expected_msg = ("Vnf instance %s in task_state ERROR. "
                       "Cannot delete while the vnf instance "
                       "is in this state.")
        self.assertEqual(expected_msg % uuidsentinel.vnf_instance_id,
                resp.json['conflictingRequest']['message']) 
开发者ID:openstack,项目名称:tacker,代码行数:21,代码来源:test_controller.py

示例11: _handle_error

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def _handle_error(url, response):
    """Handle response status codes."""
    handlers = {
        http_client.NOT_FOUND: NotFoundError(
            'Resource not found: {}'.format(url)
        ),
        # XXX: Correct code is CONFLICT. Support invalid FOUND during
        #      migration.
        http_client.FOUND: AlreadyExistsError(
            'Resource already exists: {}'.format(url)
        ),
        http_client.CONFLICT: AlreadyExistsError(
            'Resource already exists: {}'.format(url)
        ),
        http_client.TOO_MANY_REQUESTS: TooManyRequestsError(response),
        http_client.FAILED_DEPENDENCY: ValidationError(response),
        # XXX: Correct code is FORBIDDEN. Support invalid UNAUTHORIZED during
        #      migration.
        http_client.UNAUTHORIZED: NotAuthorizedError(response),
        http_client.FORBIDDEN: NotAuthorizedError(response),
        http_client.BAD_REQUEST: BadRequestError(response),
    }

    if response.status_code in handlers:
        raise handlers[response.status_code] 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:27,代码来源:restclient.py

示例12: retry_on_conflict

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def retry_on_conflict(func):
    @wraps(func)
    def retry(*args, **kwargs):
        # Only retry when OsbsResponseException was raised due to a conflict
        def should_retry_cb(ex):
            return ex.status_code == http_client.CONFLICT

        retry_func = RetryFunc(OsbsResponseException, should_retry_cb=should_retry_cb)
        return retry_func.go(func, *args, **kwargs)

    return retry 
开发者ID:containerbuildsystem,项目名称:osbs-client,代码行数:13,代码来源:__init__.py

示例13: test_get_vnf_package_vnfd_failed_with_invalid_status

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_get_vnf_package_vnfd_failed_with_invalid_status(
            self, mock_vnf_by_id):
        vnf_package_updates = {
            'onboarding_state': 'CREATED',
            'operational_state': 'DISABLED'
        }
        mock_vnf_by_id.return_value = fakes.return_vnfpkg_obj(
            vnf_package_updates=vnf_package_updates)
        req = fake_request.HTTPRequest.blank(
            '/vnf_packages/%s/vnfd'
            % constants.UUID)
        req.headers['Accept'] = 'application/zip'
        req.method = 'GET'
        resp = req.get_response(self.app)
        self.assertEqual(http_client.CONFLICT, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:17,代码来源:test_controller.py

示例14: test_instantiate_incorrect_instantiation_state

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_instantiate_incorrect_instantiation_state(self, mock_vnf_by_id):
        vnf_instance = fakes.return_vnf_instance_model()
        vnf_instance.instantiation_state = 'INSTANTIATED'
        mock_vnf_by_id.return_value = vnf_instance

        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.CONFLICT, resp.status_code) 
开发者ID:openstack,项目名称:tacker,代码行数:17,代码来源:test_controller.py

示例15: test_post_duplicate

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CONFLICT [as 别名]
def test_post_duplicate(self):
        instance = self.__create_instance()

        post_resp = self.__do_post(instance)
        self.assertEqual(post_resp.status_int, http_client.CREATED)

        post_dup_resp = self.__do_post(instance)
        self.assertEqual(post_dup_resp.status_int, http_client.CONFLICT)

        del_resp = self.__do_delete(self.__get_obj_id(post_resp))
        self.assertEqual(del_resp.status_int, http_client.NO_CONTENT) 
开发者ID:StackStorm,项目名称:st2,代码行数:13,代码来源:test_policies.py


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