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


Python http_client.NO_CONTENT属性代码示例

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


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

示例1: _test_delete_running_job

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def _test_delete_running_job(self):
        pb = 'tests/fixtures/playbooks/hello_world_with_sleep.yml'
        response = self.app.post(
            '/runs',
            data=json.dumps(dict(playbook_path=pb,
                                 inventory_file='localhost,',
                                 options={'connection': 'local',
                                          'subset': None})),
            content_type='application/json')
        res_dict = json.loads(response.data)
        self.assertEqual(http_client.CREATED, response.status_code)
        response = self.app.delete('/runs/{}'.format(res_dict['id']))
        self.assertEqual(http_client.NO_CONTENT, response.status_code)
        response = self.app.get('/runs/{}'.format(res_dict['id']))
        res_dict = json.loads(response.data)
        self.assertEqual('ABORTED', res_dict['state'])
        self._wait_for_run_complete(res_dict['id']) 
开发者ID:vmware-archive,项目名称:column,代码行数:19,代码来源:test_run.py

示例2: test_crud

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

        post_resp = self.__do_post(instance)
        self.assertEqual(post_resp.status_int, http_client.CREATED)
        get_resp = self.__do_get_one(self.__get_obj_id(post_resp))
        self.assertEqual(get_resp.status_int, http_client.OK)

        updated_input = get_resp.json
        updated_input['enabled'] = not updated_input['enabled']
        put_resp = self.__do_put(self.__get_obj_id(post_resp), updated_input)
        self.assertEqual(put_resp.status_int, http_client.OK)
        self.assertEqual(put_resp.json['enabled'], updated_input['enabled'])

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

示例3: __ProcessHttpResponse

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def __ProcessHttpResponse(self, method_config, http_response, request):
        """Process the given http response."""
        if http_response.status_code not in (http_client.OK,
                                             http_client.CREATED,
                                             http_client.NO_CONTENT):
            raise exceptions.HttpError.FromResponse(
                http_response, method_config=method_config, request=request)
        if http_response.status_code == http_client.NO_CONTENT:
            # TODO(craigcitro): Find out why _replace doesn't seem to work
            # here.
            http_response = http_wrapper.Response(
                info=http_response.info, content='{}',
                request_url=http_response.request_url)

        content = http_response.content
        if self._client.response_encoding and isinstance(content, bytes):
            content = content.decode(self._client.response_encoding)

        if self.__client.response_type_model == 'json':
            return content
        response_type = _LoadClass(method_config.response_type_name,
                                   self.__client.MESSAGES_MODULE)
        return self.__client.DeserializeMessage(response_type, content) 
开发者ID:google,项目名称:apitools,代码行数:25,代码来源:base_api.py

示例4: test_operation_invoke_with_urlopen_accept_no_content__data

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [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) 
开发者ID:suds-community,项目名称:suds,代码行数:18,代码来源:test_transport_http.py

示例5: test_operation_invoke_with_urlopen_accept_no_content__no_data

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [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 
开发者ID:suds-community,项目名称:suds,代码行数:25,代码来源:test_transport_http.py

示例6: post

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def post(self, request, sessions, *args, **kwargs):
        """Update the test data to 'in progress' state and set the start time.

        Args:
            test_id (number): the identifier of the test.
        """
        session_token = request.model.token
        try:
            session_data = sessions[session_token]
            test_data = session_data.all_tests[request.model.test_id]

        except KeyError:
            raise BadRequest("Invalid token/test_id provided "
                             "(Test timed out?)")

        test_data.start()
        test_data.save()

        return Response({}, status=http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:21,代码来源:start_composite.py

示例7: post

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def post(self, request, sessions, *args, **kwargs):
        """Add a result to the test.

        Args:
            test_id (number): the identifier of the test.
            result_code (number): code of the result as defined in TestOutcome.
            info (str): additional info (traceback / end reason etc).
        """
        session_token = request.model.test_details.token
        try:
            session_data = sessions[session_token]
            test_data = \
                session_data.all_tests[request.model.test_details.test_id]

        except KeyError:
            raise BadRequest("Invalid token/test_id provided "
                             "(Test timed out?)")

        test_data.update_result(request.model.result.result_code,
                                request.model.result.info)
        test_data.save()

        return Response({}, status=http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:25,代码来源:add_test_result.py

示例8: post

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def post(self, request, sessions, *args, **kwargs):
        """End a test run.

        Args:
            request (Request): StopTest request.
        """
        session_token = request.model.token
        try:
            session_data = sessions[session_token]
            test_data = session_data.all_tests[request.model.test_id]

        except KeyError:
            raise BadRequest("Invalid token/test_id provided "
                             "(Test timed out?)")

        test_data.end()
        test_data.save()

        return Response({}, status=http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:21,代码来源:stop_test.py

示例9: post

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def post(self, request, sessions, *args, **kwargs):
        """Save the composite test's data.

        Args:
            test_id (number): the identifier of the test.
        """
        session_token = request.model.token
        try:
            session_data = sessions[session_token]
            test_data = session_data.all_tests[request.model.test_id]

        except KeyError:
            raise BadRequest("Invalid token/test_id provided "
                             "(Test timed out?)")

        has_succeeded = all(sub_test.success for sub_test in test_data)
        test_data.success = has_succeeded
        test_data.end()
        test_data.save()

        return Response({}, status=http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:23,代码来源:stop_composite.py

示例10: put

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def put(self, request, *args, **kwargs):
        """Update content in the server's DB.

        Args:
            model (type): Django model to apply changes on.
            filter (dict): arguments to filter by.
            changes (dict): the additional arguments are the changes to
                apply on the filtered instances.
        """
        model = extract_type(request.model.resource_descriptor.type)
        filter_dict = request.model.resource_descriptor.properties
        kwargs_vars = request.model.changes
        with transaction.atomic():
            objects = model.objects.select_for_update()
            if filter_dict is not None and len(filter_dict) > 0:
                objects.filter(**filter_dict).update(**kwargs_vars)

            else:
                objects.all().update(**kwargs_vars)

        return Response({}, status=http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:23,代码来源:update_fields.py

示例11: post

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def post(self, request, sessions, *args, **kwargs):
        """Clean up user's requests and locked resources.

        Args:
            username (str): the username to cleanup.

        Returns:
            SuccessReply. a reply indicating on a successful operation.
        """
        username = get_username(request)
        session = sessions[request.model.token]
        for resource in session.resources:
            ReleaseResources.release_resource(resource, username=None)

        return Response({
            "details": "User {} was successfully cleaned".format(username)
        }, status=http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:19,代码来源:cleanup_user.py

示例12: test_update_resources

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def test_update_resources(self):
        """Assert that the request has the right server response."""
        response, _ = self.requester(
            path="tests/update_resources",
            params={
                "token": self.token,
                "test_id": self.test_case.identifier
            },
            json_data={
                "descriptors": [{
                    "type": "rotest.management.models.ut_models."
                            "DemoResourceData",
                    "properties": {
                        "name": "available_resource1"
                    }
                }]
            })
        self.assertEqual(response.status_code, http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:20,代码来源:test_test_control.py

示例13: test_start_test_stop_test

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def test_start_test_stop_test(self):
        """Assert that the request has the right server response."""
        response, _ = self.requester(path="tests/start_test",
                                     params={
                                         "token": self.token,
                                         "test_id":
                                             self.test_case.identifier
                                     })

        self.assertEqual(response.status_code, http_client.NO_CONTENT)

        response, _ = self.requester(path="tests/stop_test",
                                     params={
                                         "token": self.token,
                                         "test_id":
                                             self.test_case.identifier
                                     })
        self.assertEqual(response.status_code, http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:20,代码来源:test_test_control.py

示例14: test_start_test_stop_composite

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def test_start_test_stop_composite(self):
        """Assert that the request has the right server response."""
        response, _ = self.requester(path="tests/start_composite",
                                     params={
                                         "token": self.token,
                                         "test_id":
                                             self.test_case.identifier
                                     })
        self.assertEqual(response.status_code, http_client.NO_CONTENT)

        response, _ = self.requester(path="tests/stop_composite",
                                     params={
                                         "token": self.token,
                                         "test_id":
                                             self.test_case.identifier
                                     })
        self.assertEqual(response.status_code, http_client.NO_CONTENT) 
开发者ID:gregoil,项目名称:rotest,代码行数:19,代码来源:test_test_control.py

示例15: test_release_owner_complex_resource

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import NO_CONTENT [as 别名]
def test_release_owner_complex_resource(self):
        """Assert response - cleanup of complex resource."""
        resources = DemoComplexResourceData.objects.filter(
            name='complex_resource1')

        resource, = resources
        sub_resource = resource.demo1

        resource.owner = "localhost"
        sub_resource.owner = "localhost"
        resource.save()
        sub_resource.save()
        SESSIONS[self.token].resources = [resource]
        response, _ = self.requester(json_data={"token": self.token})
        self.assertEqual(response.status_code, http_client.NO_CONTENT)

        resources = DemoComplexResourceData.objects.filter(
            name='complex_resource1')

        resource, = resources
        sub_resource = resource.demo1

        self.assertEqual(resource.owner, "")
        self.assertEqual(sub_resource.owner, "") 
开发者ID:gregoil,项目名称:rotest,代码行数:26,代码来源:test_cleanup_user.py


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