How to use the scanapi.errors.HTTPMethodNotAllowedError function in scanapi

To help you get started, we’ve selected a few scanapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github camilamaia / scanapi / tests / unit / tree / test_request_node.py View on Github external
def test_when_method_is_invalid(self):
            request = RequestNode(
                {"method": "xxx", "name": "foo", "path": "http:foo.com"},
                endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
            )
            with pytest.raises(HTTPMethodNotAllowedError) as excinfo:
                request.http_method

            assert (
                str(excinfo.value) == "HTTP method not supported: XXX. "
                "Supported methods: ('GET', 'POST', 'PUT', 'PATCH', 'DELETE')."
github camilamaia / scanapi / tests / unit / test_request_maker.py View on Github external
def test_should_raise_http_method_not_allowed_error(self, api_tree):
                requests_maker = RequestsMakerFactory(api_tree=api_tree)
                request_node = requests_maker.api_tree.request_nodes[0]
                with pytest.raises(HTTPMethodNotAllowedError) as excinfo:
                    requests_maker.make_request(request_node)

                assert (
                    str(excinfo.value)
                    == "HTTP method not supported: PET. Supported methods: "
                    "('GET', 'POST', 'PUT', 'PATCH', 'DELETE')."
github camilamaia / scanapi / scanapi / tree / request_node.py View on Github external
def http_method(self):
        method = self.spec.get("method", "get").upper()
        if method not in self.ALLOWED_HTTP_METHODS:
            raise HTTPMethodNotAllowedError(method, self.ALLOWED_HTTP_METHODS)

        return method
github camilamaia / scanapi / scanapi / requests_maker.py View on Github external
def make_request(self, request):
        method = request.method.upper()

        if method not in self.ALLOWED_HTTP_METHODS:
            raise HTTPMethodNotAllowedError(method, self.ALLOWED_HTTP_METHODS)

        return requests.request(
            method,
            request.url,
            headers=request.headers,
            params=request.params,
            json=request.body,
            allow_redirects=False,
        )
github camilamaia / scanapi / scanapi / tree / request_node.py View on Github external
def http_method(self):
        method = self.spec.get(METHOD_KEY, "get").upper()
        if method not in self.ALLOWED_HTTP_METHODS:
            raise HTTPMethodNotAllowedError(method, self.ALLOWED_HTTP_METHODS)

        return method
github camilamaia / scanapi / scanapi / requests_maker.py View on Github external
def make_request(self, request):
        method = request.method.upper()

        if method not in self.ALLOWED_HTTP_METHODS:
            raise HTTPMethodNotAllowedError(method, self.ALLOWED_HTTP_METHODS)

        return requests.request(
            method,
            request.url,
            headers=request.headers,
            params=request.params,
            json=request.body,
            allow_redirects=False,
        )
github camilamaia / scanapi / scanapi / errors.py View on Github external
def __init__(self, method, allowed_methos, *args):
        message = (
            f"HTTP method not supported: {method}. Supported methods: {allowed_methos}."
        )
        super(HTTPMethodNotAllowedError, self).__init__(message, *args)