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


Python HTTPStatus.METHOD_NOT_ALLOWED屬性代碼示例

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


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

示例1: test_delete_study_error

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_delete_study_error(httpserver, client, cache_dir):
    study_instance_uid = '1.2.3'
    httpserver.serve_content(
        content='',
        code=HTTPStatus.METHOD_NOT_ALLOWED,
        headers=''
    )
    with pytest.raises(HTTPError):
        client.delete_study(study_instance_uid=study_instance_uid)
    assert len(httpserver.requests) == 1
    request = httpserver.requests[0]
    expected_path = (
        '/studies/{study_instance_uid}'.format(
            study_instance_uid=study_instance_uid)
    )
    assert request.path == expected_path
    assert request.method == 'DELETE' 
開發者ID:MGHComputationalPathology,項目名稱:dicomweb-client,代碼行數:19,代碼來源:test_api.py

示例2: test_delete_series_error

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_delete_series_error(httpserver, client, cache_dir):
    study_instance_uid = '1.2.3'
    series_instance_uid = '1.2.4'
    httpserver.serve_content(
        content='',
        code=HTTPStatus.METHOD_NOT_ALLOWED,
        headers=''
    )
    with pytest.raises(HTTPError):
        client.delete_series(study_instance_uid=study_instance_uid,
                             series_instance_uid=series_instance_uid)
    assert len(httpserver.requests) == 1
    request = httpserver.requests[0]
    expected_path = (
        '/studies/{study_instance_uid}/series/{series_instance_uid}'.format(
            study_instance_uid=study_instance_uid,
            series_instance_uid=series_instance_uid)
    )
    assert request.path == expected_path
    assert request.method == 'DELETE' 
開發者ID:MGHComputationalPathology,項目名稱:dicomweb-client,代碼行數:22,代碼來源:test_api.py

示例3: test_delete_instance_error

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_delete_instance_error(httpserver, client, cache_dir):
    study_instance_uid = '1.2.3'
    series_instance_uid = '1.2.4'
    sop_instance_uid = '1.2.5'
    httpserver.serve_content(
        content='',
        code=HTTPStatus.METHOD_NOT_ALLOWED,
        headers=''
    )
    with pytest.raises(HTTPError):
        client.delete_instance(study_instance_uid=study_instance_uid,
                               series_instance_uid=series_instance_uid,
                               sop_instance_uid=sop_instance_uid)
    assert len(httpserver.requests) == 1
    request = httpserver.requests[0]
    expected_path = (
        '/studies/{study_instance_uid}/series/{series_instance_uid}/instances'
        '/{sop_instance_uid}'.format(
            study_instance_uid=study_instance_uid,
            series_instance_uid=series_instance_uid,
            sop_instance_uid=sop_instance_uid,)
    )
    assert request.path == expected_path
    assert request.method == 'DELETE' 
開發者ID:MGHComputationalPathology,項目名稱:dicomweb-client,代碼行數:26,代碼來源:test_api.py

示例4: __init__

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def __init__(self, allowed_methods: Optional[Iterable[str]] = None) -> None:
        super().__init__(HTTPStatus.METHOD_NOT_ALLOWED)
        self.allowed_methods = allowed_methods 
開發者ID:pgjones,項目名稱:quart,代碼行數:5,代碼來源:exceptions.py

示例5: _send_405

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def _send_405(request):
    raise ResponseError(status=HTTPStatus.METHOD_NOT_ALLOWED) 
開發者ID:wasp,項目名稱:waspy,代碼行數:4,代碼來源:router.py

示例6: method_not_allowed

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def method_not_allowed(self) -> web.Response:
        return web.json_response({
            "error": "Method not allowed",
            "errcode": "method_not_allowed",
        }, status=HTTPStatus.METHOD_NOT_ALLOWED) 
開發者ID:maubot,項目名稱:maubot,代碼行數:7,代碼來源:responses.py

示例7: do_405

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def do_405(environ, start_response):
    """
    Generic app to produce a 405
    """
    urlpath = environ['SCRIPT_NAME'] + environ['PATH_INFO']

    return send_simple_text(
        environ, start_response, HTTPStatus.METHOD_NOT_ALLOWED,
        "Method {} is not allowed on {}".format(
            environ['REQUEST_METHOD'], urlpath,
        ),
    ) 
開發者ID:r0x0r,項目名稱:pywebview,代碼行數:14,代碼來源:wsgi.py

示例8: test_logout_GET_returns_405

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_logout_GET_returns_405(self):
        password = factory.make_string()
        user = factory.make_User(password=password)
        self.client.handler.enforce_csrf_checks = True
        self.client.login(username=user.username, password=password)
        self.client.handler.enforce_csrf_checks = False
        response = self.client.get(reverse("logout"))
        self.assertThat(
            response, HasStatusCode(http.client.METHOD_NOT_ALLOWED)
        ) 
開發者ID:maas,項目名稱:maas,代碼行數:12,代碼來源:test_account.py

示例9: test_rejects_GET

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_rejects_GET(self):
        response = self.client.get(reverse("authenticate"))
        self.assertThat(response, HasStatusCode(HTTPStatus.METHOD_NOT_ALLOWED))
        self.assertThat(response["Allow"], Equals("POST")) 
開發者ID:maas,項目名稱:maas,代碼行數:6,代碼來源:test_account.py

示例10: test_method_not_allowed_on_get

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_method_not_allowed_on_get(self):
        response = self.client.get(reverse("csrf"))
        self.assertThat(response, HasStatusCode(HTTPStatus.METHOD_NOT_ALLOWED)) 
開發者ID:maas,項目名稱:maas,代碼行數:5,代碼來源:test_account.py

示例11: test_method_not_allowed_on_put

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_method_not_allowed_on_put(self):
        response = self.client.put(reverse("csrf"))
        self.assertThat(response, HasStatusCode(HTTPStatus.METHOD_NOT_ALLOWED)) 
開發者ID:maas,項目名稱:maas,代碼行數:5,代碼來源:test_account.py

示例12: test_method_not_allowed_on_delete

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def test_method_not_allowed_on_delete(self):
        response = self.client.delete(reverse("csrf"))
        self.assertThat(response, HasStatusCode(HTTPStatus.METHOD_NOT_ALLOWED)) 
開發者ID:maas,項目名稱:maas,代碼行數:5,代碼來源:test_account.py

示例13: _http_delete

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def _http_delete(self, url: str):
        '''Performs a HTTP DELETE request to the specified URL.

        Parameters
        ----------
        url: str
            unique resource locator

        Returns
        -------
        requests.models.Response
            HTTP response message
        '''
        @retrying.retry(
            retry_on_result=self._is_retriable_http_error,
            wait_exponential_multiplier=self._wait_exponential_multiplier,
            stop_max_attempt_number=self._max_attempts
        )
        def _invoke_delete_request(url: str) -> requests.models.Response:
            return self._session.delete(url)

        response = _invoke_delete_request(url)
        if response.status_code == HTTPStatus.METHOD_NOT_ALLOWED:
            logger.error(
              'Resource could not be deleted. The origin server may not support'
              'deletion or you may not have the necessary permissions.')
        response.raise_for_status()
        return response 
開發者ID:MGHComputationalPathology,項目名稱:dicomweb-client,代碼行數:30,代碼來源:api.py

示例14: get

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def get(self, *args, **kwargs):
        return Response(status=HTTPStatus.METHOD_NOT_ALLOWED) 
開發者ID:openzim,項目名稱:zimfarm,代碼行數:4,代碼來源:base.py

示例15: post

# 需要導入模塊: from http import HTTPStatus [as 別名]
# 或者: from http.HTTPStatus import METHOD_NOT_ALLOWED [as 別名]
def post(self, *args, **kwargs):
        return Response(status=HTTPStatus.METHOD_NOT_ALLOWED) 
開發者ID:openzim,項目名稱:zimfarm,代碼行數:4,代碼來源:base.py


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