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


Python http_client.CREATED属性代码示例

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


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

示例1: _test_get_run_by_id

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def _test_get_run_by_id(self):
        response = self.app.get('/runs/1234')
        self.assertEqual(http_client.NOT_FOUND, response.status_code)

        pb = 'tests/fixtures/playbooks/hello_world.yml'
        response = self.app.post(
            '/runs',
            data=json.dumps(dict(playbook_path=pb,
                                 inventory_file='localhosti,',
                                 options={'connection': 'local'})),
            content_type='application/json')
        res_dict = json.loads(response.data)
        run_id = res_dict['id']
        self.assertEqual(http_client.CREATED, response.status_code)
        response = self.app.get('/runs/{}'.format(run_id))
        self.assertEqual(http_client.OK, response.status_code)
        self._wait_for_run_complete(run_id) 
开发者ID:vmware-archive,项目名称:column,代码行数:19,代码来源:test_run.py

示例2: _test_get_run_list

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def _test_get_run_list(self):
        pb = 'tests/fixtures/playbooks/hello_world.yml'
        response = self.app.post(
            '/runs',
            data=json.dumps(dict(playbook_path=pb,
                                 inventory_file='localhost,',
                                 options={'connection': 'local'})),
            content_type='application/json')
        res_dict = json.loads(response.data)
        run_id = res_dict['id']
        self.assertEqual(http_client.CREATED, response.status_code)
        response = self.app.get('/runs')
        res_list = json.loads(response.data)
        found = False
        for item in res_list:
            if item['id'] == run_id:
                found = True
                break
        self.assertEqual(True, found)
        self._wait_for_run_complete(run_id) 
开发者ID:vmware-archive,项目名称:column,代码行数:22,代码来源:test_run.py

示例3: _test_delete_running_job

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [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

示例4: _authorize

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def _authorize(self):
        """Performs authorization setting x-auth-session."""
        self.headers['authorization'] = 'Basic %s' % self.auth_str
        if 'x-auth-session' in self.headers:
            del self.headers['x-auth-session']

        try:
            result = self.post("/access/v1")
            del self.headers['authorization']
            if result.status == http_client.CREATED:
                self.headers['x-auth-session'] = (
                    result.get_header('x-auth-session'))
                self.do_logout = True
                log_debug_msg(self, ('ZFSSA version: %s')
                              % result.get_header('x-zfssa-version'))

            elif result.status == http_client.NOT_FOUND:
                raise RestClientError(result.status, name="ERR_RESTError",
                                      message=("REST Not Available:"
                                               "Please Upgrade"))

        except RestClientError:
            del self.headers['authorization']
            raise 
开发者ID:openstack,项目名称:manila,代码行数:26,代码来源:restclient.py

示例5: test_create_success_with_201_response_code

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def test_create_success_with_201_response_code(
        self, mock_client, mock_create):
        body = {
            "host": {
                "name": "host-1", "type": "fake",
                "reserved": False,
                "on_maintenance": False,
                "control_attributes": "fake-control_attributes"
            }
        }
        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.CREATED, resp.status_code) 
开发者ID:openstack,项目名称:masakari,代码行数:18,代码来源:test_hosts.py

示例6: test_create_success_with_201_response_code

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def test_create_success_with_201_response_code(
        self, mock_client, mock_create):
        body = {
            "segment": {
                "name": "segment1",
                "service_type": "COMPUTE",
                "recovery_method": "auto",
                "description": "failover_segment for compute"
            }
        }
        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.CREATED, resp.status_code) 
开发者ID:openstack,项目名称:masakari,代码行数:18,代码来源:test_segments.py

示例7: create

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def create(self, request, body):
        context = request.environ['tacker.context']
        context.can(vnf_package_policies.VNFPKGM % 'create')

        vnf_package = vnf_package_obj.VnfPackage(context=request.context)
        vnf_package.onboarding_state = (
            fields.PackageOnboardingStateType.CREATED)
        vnf_package.operational_state = (
            fields.PackageOperationalStateType.DISABLED)
        vnf_package.usage_state = fields.PackageUsageStateType.NOT_IN_USE
        vnf_package.user_data = body.get('userDefinedData', dict())
        vnf_package.tenant_id = request.context.project_id

        vnf_package.create()

        return self._view_builder.create(request, vnf_package) 
开发者ID:openstack,项目名称:tacker,代码行数:18,代码来源:controller.py

示例8: test_upload_vnf_package_from_uri

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

示例9: test_patch_update_existing_user_data

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def test_patch_update_existing_user_data(self, mock_save, mock_vnf_by_id):
        fake_obj = fakes.return_vnfpkg_obj(vnf_package_updates={
            "operational_state": "DISABLED", "onboarding_state": "CREATED",
            "user_data": {"testKey1": "val01", "testKey2": "val02",
            "testKey3": "val03"}})
        mock_vnf_by_id.return_value = fake_obj
        req_body = {"userDefinedData": {"testKey1": "changed_val01",
                                        "testKey2": "changed_val02",
                                        "testKey3": "changed_val03"}}
        req = fake_request.HTTPRequest.blank(
            '/vnf_packages/%s'
            % constants.UUID)
        req.headers['Content-Type'] = 'application/json'
        req.method = 'PATCH'
        req.body = jsonutils.dump_as_bytes(req_body)
        resp = req.get_response(self.app)
        self.assertEqual(http_client.OK, resp.status_code)
        self.assertEqual(req_body, jsonutils.loads(resp.body)) 
开发者ID:openstack,项目名称:tacker,代码行数:20,代码来源:test_controller.py

示例10: test_patch_failed_with_same_user_data

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def test_patch_failed_with_same_user_data(self, mock_save,
                                              mock_vnf_by_id):
        vnf_package_updates = {"operational_state": "DISABLED",
            "onboarding_state": "CREATED",
            "user_data": {"testKey1": "val01",
                          "testKey2": "val02",
                          "testkey3": "val03"}}
        req_body = {"userDefinedData": {"testKey1": "val01",
                                        "testKey2": "val02",
                                        "testkey3": "val03"}}
        fake_obj = fakes.return_vnfpkg_obj(
            vnf_package_updates=vnf_package_updates)
        mock_vnf_by_id.return_value = fake_obj

        req = fake_request.HTTPRequest.blank('/vnf_packages/%s'
                                             % constants.UUID)
        self.assertRaises(exc.HTTPConflict,
                          self.controller.patch,
                          req, constants.UUID, body=req_body) 
开发者ID:openstack,项目名称:tacker,代码行数:21,代码来源:test_controller.py

示例11: test_crud

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [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

示例12: test_put_sys_pack

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

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

        updated_input = post_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.BAD_REQUEST)
        self.assertEqual(put_resp.json['faultstring'],
                         "Resources belonging to system level packs can't be manipulated")

        # Clean up manually since API won't delete object in sys pack.
        Policy.delete(Policy.get_by_id(self.__get_obj_id(post_resp))) 
开发者ID:StackStorm,项目名称:st2,代码行数:18,代码来源:test_policies.py

示例13: __ProcessHttpResponse

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [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

示例14: test_create

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def test_create(self, mock_obj_extarq, mock_obj_dp):
        dp_list = fake_device_profile.get_obj_devprofs()
        mock_obj_dp.return_value = dp = dp_list[0]
        mock_obj_extarq.side_effect = self.fake_extarqs
        params = {'device_profile_name': dp['name']}
        response = self.post_json(self.ARQ_URL, params, headers=self.headers)
        data = jsonutils.loads(response.__dict__['controller_output'])
        out_arqs = data['arqs']

        self.assertEqual(http_client.CREATED, response.status_int)
        self.assertEqual(len(out_arqs), 3)
        for in_extarq, out_arq in zip(self.fake_extarqs, out_arqs):
            self._validate_arq(in_extarq.arq, out_arq)
        for idx, out_arq in enumerate(out_arqs):
            dp_group_id = idx
            self.assertEqual(dp_group_id, out_arq['device_profile_group_id']) 
开发者ID:openstack,项目名称:cyborg,代码行数:18,代码来源:test_arqs.py

示例15: check_response

# 需要导入模块: from six.moves import http_client [as 别名]
# 或者: from six.moves.http_client import CREATED [as 别名]
def check_response(response, log_level=logging.ERROR):
    if response.status_code not in (http_client.OK, http_client.CREATED):
        if hasattr(response, 'content'):
            content = response.content
        else:
            content = b''.join(response.iter_lines())

        logger.log(log_level, "[%d] %s", response.status_code, content)
        raise OsbsResponseException(message=content, status_code=response.status_code)


# TODO: error handling: create function which handles errors in response object 
开发者ID:containerbuildsystem,项目名称:osbs-client,代码行数:14,代码来源:core.py


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