當前位置: 首頁>>代碼示例>>Python>>正文


Python HTTPStatus.ACCEPTED屬性代碼示例

本文整理匯總了Python中http.HTTPStatus.ACCEPTED屬性的典型用法代碼示例。如果您正苦於以下問題:Python HTTPStatus.ACCEPTED屬性的具體用法?Python HTTPStatus.ACCEPTED怎麽用?Python HTTPStatus.ACCEPTED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在http.HTTPStatus的用法示例。


在下文中一共展示了HTTPStatus.ACCEPTED屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _update_job

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def _update_job(
    job: ScheduledJob, user: User, account: Account
) -> Response:
    try:
        updated_job = await ScheduledJobsService.update_job(
            job, user, account, ChronosScheduledJobsBackend()
        )
    except NotFoundEntity as e:
        return json_response(
            ErrorResource(errors=[ErrorDetail(msg=str(e))]).dict(),
            status=HTTPStatus.NOT_FOUND,
        )

    return json_response(
        CreateScheduledJobResource(job=updated_job).dict(),
        status=HTTPStatus.ACCEPTED,
    ) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:19,代碼來源:jobs.py

示例2: check_provision

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def check_provision(self, instace_guid, org_guid, space_guid, service_guid, plan_guid):
        response = requests.put(
            "http://localhost:5001/v2/service_instances/{}?accepts_incomplete=true".format(instace_guid),
            data=json.dumps({
                "organization_guid": org_guid,
                "space_guid": space_guid,
                "service_id": service_guid,
                "plan_id": plan_guid,
                # "context": {
                #     "organization_guid": "org-guid-here",
                #     "space_guid": "space-guid-here",
                # }
            }),
            **self.request_ads)
        self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)

        operation = response.json().get('operation')
        self.assertEqual('provision', operation)

        return operation 
開發者ID:eruvanos,項目名稱:openbrokerapi,代碼行數:22,代碼來源:test_integration_using_async_flow.py

示例3: rpc

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def rpc(addr: str, req: Request, pid: Pid, seqno: Seqno):
    """Issues a coordinator call asynchronously.  If the call is blocking, raises WouldBlock."""
    assert addr, "The RPC server address must not be empty."

    with log_duration(pid, seqno, "rpc"):
        conn = http.client.HTTPConnection(addr, timeout=RPC_HTTP_TIMEOUT)  # type: ignore
        # mypy thinks `timeout` has to be an `int`, but passing a `float` doesn't seem to be a problem.

        req_str = str(req)
        log(pid, seqno, f"rpc size: {len(req_str)}")

        conn.request("POST", "", str(req))
        res = conn.getresponse()
        body = res.read()

    if res.status == HTTPStatus.OK:
        return json.loads(body)
    elif res.status == HTTPStatus.ACCEPTED:  # Coordinator call is blocking.
        raise WouldBlock()

    raise RPCError(status=HTTPStatus(res.status).description, message=body.decode("utf-8")) 
開發者ID:NetSys,項目名稱:kappa,代碼行數:23,代碼來源:rpc.py

示例4: patch

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def patch(self, requested_task_id: str, token: AccessToken.Payload):

        requested_task = RequestedTasks().count_documents({"_id": requested_task_id})
        if not requested_task:
            raise TaskNotFound()

        try:
            request_json = UpdateRequestedTaskSchema().load(request.get_json())
        except ValidationError as e:
            raise InvalidRequestJSON(e.messages)

        update = RequestedTasks().update_one(
            {"_id": requested_task_id},
            {"$set": {"priority": request_json.get("priority", 0)}},
        )
        if update.modified_count:
            return Response(status=HTTPStatus.ACCEPTED)
        return Response(status=HTTPStatus.OK) 
開發者ID:openzim,項目名稱:zimfarm,代碼行數:20,代碼來源:requested_task.py

示例5: post

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def post(self):
        """
        A webhook used by Packit-as-a-Service GitHub App.
        """
        msg = request.json

        if not msg:
            logger.debug("/webhooks/github: we haven't received any JSON data.")
            github_webhook_calls.labels(result="no_data").inc()
            return "We haven't received any JSON data.", HTTPStatus.BAD_REQUEST

        if all([msg.get("zen"), msg.get("hook_id"), msg.get("hook")]):
            logger.debug(f"/webhooks/github received ping event: {msg['hook']}")
            github_webhook_calls.labels(result="pong").inc()
            return "Pong!", HTTPStatus.OK

        try:
            self.validate_signature()
        except ValidationFailed as exc:
            logger.info(f"/webhooks/github {exc}")
            github_webhook_calls.labels(result="invalid_signature").inc()
            return str(exc), HTTPStatus.UNAUTHORIZED

        if not self.interested():
            github_webhook_calls.labels(result="not_interested").inc()
            return "Thanks but we don't care about this event", HTTPStatus.ACCEPTED

        # TODO: define task names at one place
        celery_app.send_task(
            name="task.steve_jobs.process_message", kwargs={"event": msg}
        )
        github_webhook_calls.labels(result="accepted").inc()

        return "Webhook accepted. We thank you, Github.", HTTPStatus.ACCEPTED 
開發者ID:packit-service,項目名稱:packit-service,代碼行數:36,代碼來源:webhooks.py

示例6: update_user_partial

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def update_user_partial(user_id: str, wrapper: RequestWrapper):

    try:
        body_data = await wrapper.http_request.json()
    except JSONDecodeError as e:
        return web.json_response(
            ErrorResource(errors=[ErrorDetail(msg=str(e))]).dict(),
            status=HTTPStatus.UNPROCESSABLE_ENTITY,
        )

    user = await UsersService.get_user_by_id(int(user_id), UsersBackend())
    status_code = HTTPStatus.ACCEPTED if user else HTTPStatus.NOT_FOUND

    try:
        if user:
            body_user = User(**body_data)
            user.name = body_user.name if body_user.name else user.name
            user.email = body_user.email if body_user.email else user.email
            updated_user = await UsersService.update_user(user, UsersBackend())
    except DuplicateEntity as de:
        return web.json_response(
            ErrorResource(errors=[ErrorDetail(msg=str(de))]).dict(),
            status=status_code,
        )

    return web.json_response(
        UserResource(user=updated_user).dict(), status=status_code
    ) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:30,代碼來源:users.py

示例7: test_update_user_update_only_name

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_update_user_update_only_name(self):
        expected_new_name = "Novo Nome"
        new_user_data = {"name": expected_new_name}

        resp = await self.client.patch(
            f"/users/{USER_WITH_MULTIPLE_ACCOUNTS_ID}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            json=new_user_data,
        )
        self.assertEqual(HTTPStatus.ACCEPTED, resp.status)
        user_data = await resp.json()

        new_user = User(**USER_WITH_MULTIPLE_ACCOUNTS_DICT)
        new_user.name = expected_new_name
        self.assertEqual(UserResource(user=new_user).dict(), user_data)

        resp = await self.client.get(
            f"/users/{USER_WITH_MULTIPLE_ACCOUNTS_ID}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
        )
        updated_user_data = await resp.json()
        self.assertEqual(UserResource(user=new_user).dict(), updated_user_data) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:28,代碼來源:test_users.py

示例8: test_update_user_update_all_fields

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_update_user_update_all_fields(self):
        expected_new_name = "Novo Nome"
        expected_new_email = "newemail@server.com"

        new_user = User(**USER_WITH_MULTIPLE_ACCOUNTS_DICT)
        new_user.name = expected_new_name
        new_user.email = expected_new_email

        resp = await self.client.patch(
            f"/users/{USER_WITH_MULTIPLE_ACCOUNTS_ID}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            json=new_user.dict(),
        )
        self.assertEqual(HTTPStatus.ACCEPTED, resp.status)
        user_data = await resp.json()

        self.assertEqual(UserResource(user=new_user).dict(), user_data)

        resp = await self.client.get(
            f"/users/{USER_WITH_MULTIPLE_ACCOUNTS_ID}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
        )
        updated_user_data = await resp.json()
        self.assertEqual(UserResource(user=new_user).dict(), updated_user_data) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:30,代碼來源:test_users.py

示例9: test_update_job_on_alternate_account

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_update_job_on_alternate_account(self, infra_job_fixture):
        """
        Confirmar que podemos fazer PUT /jobs?account_id=<id>
        o job será criado com o namespace da account de id = <id>
        """
        account = Account(**ACCOUNT_INFRA_DICT)
        await _load_jobs_into_chronos(infra_job_fixture)
        asgard_job = ChronosScheduledJobConverter.to_asgard_model(
            ChronosJob(**infra_job_fixture)
        )

        asgard_job.remove_namespace(account)
        self.assertEqual(asgard_job.cpus, infra_job_fixture["cpus"])
        self.assertEqual(asgard_job.mem, infra_job_fixture["mem"])

        asgard_job.cpus = 2
        asgard_job.mem = 2048

        resp = await self.client.put(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            params={"account_id": ACCOUNT_INFRA_ID},
            json=asgard_job.dict(),
        )
        self.assertEqual(HTTPStatus.ACCEPTED, resp.status)
        updated_job_response = await self.client.get(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            params={"account_id": ACCOUNT_INFRA_ID},
        )
        updated_job_data = await updated_job_response.json()
        updated_job_resource = CreateScheduledJobResource(**updated_job_data)
        self.assertEqual(asgard_job.cpus, updated_job_resource.job.cpus)
        self.assertEqual(asgard_job.mem, updated_job_resource.job.mem) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:40,代碼來源:test_jobs.py

示例10: test_update_job_job_exist

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_update_job_job_exist(self, dev_job_fixture):
        """
        Conferimos que um job é atualizado corretamente
        """
        await _load_jobs_into_chronos(dev_job_fixture)
        asgard_job = ChronosScheduledJobConverter.to_asgard_model(
            ChronosJob(**dev_job_fixture)
        )

        asgard_job.remove_namespace(self.account)
        self.assertEqual(asgard_job.cpus, dev_job_fixture["cpus"])
        self.assertEqual(asgard_job.mem, dev_job_fixture["mem"])

        asgard_job.cpus = 2
        asgard_job.mem = 2048

        resp = await self.client.put(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            json=asgard_job.dict(),
        )
        self.assertEqual(HTTPStatus.ACCEPTED, resp.status)
        updated_job_response = await self.client.get(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
        )
        updated_job_data = await updated_job_response.json()
        updated_job_resource = CreateScheduledJobResource(**updated_job_data)
        self.assertEqual(asgard_job.cpus, updated_job_resource.job.cpus)
        self.assertEqual(asgard_job.mem, updated_job_resource.job.mem) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:36,代碼來源:test_jobs.py

示例11: test_update_job_job_exist_put_on_root_endpoint

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_update_job_job_exist_put_on_root_endpoint(
        self, dev_job_fixture
    ):
        """
        Confirmamos que é possível fazer um PUT /jobs e atualizar um job
        """
        await _load_jobs_into_chronos(dev_job_fixture)
        asgard_job = ChronosScheduledJobConverter.to_asgard_model(
            ChronosJob(**dev_job_fixture)
        )

        asgard_job.remove_namespace(self.account)
        self.assertEqual(asgard_job.cpus, dev_job_fixture["cpus"])
        self.assertEqual(asgard_job.mem, dev_job_fixture["mem"])

        asgard_job.cpus = 2
        asgard_job.mem = 2048

        resp = await self.client.put(
            f"/jobs",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            json=asgard_job.dict(),
        )
        self.assertEqual(HTTPStatus.ACCEPTED, resp.status)
        updated_job_response = await self.client.get(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
        )
        updated_job_data = await updated_job_response.json()
        updated_job_resource = CreateScheduledJobResource(**updated_job_data)
        self.assertEqual(asgard_job.cpus, updated_job_resource.job.cpus)
        self.assertEqual(asgard_job.mem, updated_job_resource.job.mem) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:38,代碼來源:test_jobs.py

示例12: test_update_job_name_has_namespace_from_another_account

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_update_job_name_has_namespace_from_another_account(
        self, dev_job_fixture
    ):
        """
        Mesmo que um job tenha o nome começado pelo namespace de outra conta,
        devemos atualizar o job da conta correta, que é a conta do usuário fazendo
        o request
        """
        self.maxDiff = None
        dev_job_fixture["name"] = f"dev-infra-{dev_job_fixture['name']}"
        await _load_jobs_into_chronos(dev_job_fixture)
        asgard_job = ChronosScheduledJobConverter.to_asgard_model(
            ChronosJob(**dev_job_fixture)
        )

        asgard_job.remove_namespace(self.account)
        self.assertEqual(asgard_job.cpus, dev_job_fixture["cpus"])
        self.assertEqual(asgard_job.mem, dev_job_fixture["mem"])

        asgard_job.cpus = 4
        asgard_job.mem = 512

        resp = await self.client.put(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
            json=asgard_job.dict(),
        )
        self.assertEqual(HTTPStatus.ACCEPTED, resp.status)

        updated_job_response = await self.client.get(
            f"/jobs/{asgard_job.id}",
            headers={
                "Authorization": f"Token {USER_WITH_MULTIPLE_ACCOUNTS_AUTH_KEY}"
            },
        )
        updated_job_data = await updated_job_response.json()
        updated_job_resource = CreateScheduledJobResource(**updated_job_data)
        self.assertEqual(asgard_job.cpus, updated_job_resource.job.cpus)
        self.assertEqual(asgard_job.mem, updated_job_resource.job.mem) 
開發者ID:b2wdigital,項目名稱:asgard-api,代碼行數:43,代碼來源:test_jobs.py

示例13: test_http_status_to_canonical_code

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def test_http_status_to_canonical_code(self):
        for status_code, expected in (
            (HTTPStatus.OK, StatusCanonicalCode.OK),
            (HTTPStatus.ACCEPTED, StatusCanonicalCode.OK),
            (HTTPStatus.IM_USED, StatusCanonicalCode.OK),
            (HTTPStatus.MULTIPLE_CHOICES, StatusCanonicalCode.OK),
            (HTTPStatus.BAD_REQUEST, StatusCanonicalCode.INVALID_ARGUMENT),
            (HTTPStatus.UNAUTHORIZED, StatusCanonicalCode.UNAUTHENTICATED),
            (HTTPStatus.FORBIDDEN, StatusCanonicalCode.PERMISSION_DENIED),
            (HTTPStatus.NOT_FOUND, StatusCanonicalCode.NOT_FOUND),
            (
                HTTPStatus.UNPROCESSABLE_ENTITY,
                StatusCanonicalCode.INVALID_ARGUMENT,
            ),
            (
                HTTPStatus.TOO_MANY_REQUESTS,
                StatusCanonicalCode.RESOURCE_EXHAUSTED,
            ),
            (HTTPStatus.NOT_IMPLEMENTED, StatusCanonicalCode.UNIMPLEMENTED),
            (HTTPStatus.SERVICE_UNAVAILABLE, StatusCanonicalCode.UNAVAILABLE),
            (
                HTTPStatus.GATEWAY_TIMEOUT,
                StatusCanonicalCode.DEADLINE_EXCEEDED,
            ),
            (
                HTTPStatus.HTTP_VERSION_NOT_SUPPORTED,
                StatusCanonicalCode.INTERNAL,
            ),
            (600, StatusCanonicalCode.UNKNOWN),
            (99, StatusCanonicalCode.UNKNOWN),
        ):
            with self.subTest(status_code=status_code):
                actual = http_status_to_canonical_code(int(status_code))
                self.assertEqual(actual, expected, status_code) 
開發者ID:open-telemetry,項目名稱:opentelemetry-python,代碼行數:36,代碼來源:test_utils.py

示例14: check_unbind

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def check_unbind(self, binding_guid, instace_guid):
        response = requests.delete(
            "http://localhost:5001/v2/service_instances/{}/service_bindings/{}".format(instace_guid, binding_guid),
            params={
                "service_id": self.service_guid,
                "plan_id": self.plan_guid,
                'accepts_incomplete': 'true'
            },
            **self.request_ads
        )
        self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)
        operation = response.json().get('operation')
        self.assertEqual('unbind', operation)
        return operation 
開發者ID:eruvanos,項目名稱:openbrokerapi,代碼行數:16,代碼來源:test_integration_using_async_flow.py

示例15: check_bind

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import ACCEPTED [as 別名]
def check_bind(self, binding_guid, instace_guid):
        response = requests.put(
            "http://localhost:5001/v2/service_instances/{}/service_bindings/{}?accepts_incomplete=true".format(
                instace_guid, binding_guid),
            data=json.dumps({
                "service_id": self.service_guid,
                "plan_id": self.plan_guid
            }),
            **self.request_ads
        )
        self.assertEqual(HTTPStatus.ACCEPTED, response.status_code)
        operation = response.json().get('operation')
        self.assertEqual('bind', operation)
        return operation 
開發者ID:eruvanos,項目名稱:openbrokerapi,代碼行數:16,代碼來源:test_integration_using_async_flow.py


注:本文中的http.HTTPStatus.ACCEPTED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。