How to use scanapi - 10 common examples

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 / test_session.py View on Github external
def test_exit_with_proper_error(self, failures, errors, error_code):
            session = Session()
            session.failures = failures
            session.errors = errors
            with pytest.raises(SystemExit) as excinfo:
                session.exit()

            assert excinfo.type == SystemExit
            assert excinfo.value.code == error_code
github camilamaia / scanapi / tests / unit / tree / test_request_node.py View on Github external
def test_calls_evaluate(self, mocker, mock_evaluate):
            request = RequestNode(
                {"body": {"ghi": "jkl"}, "path": "http://foo.com", "name": "foo"},
                endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
            )
            request.body
            calls = [mocker.call({"ghi": "jkl"})]

            mock_evaluate.assert_has_calls(calls)
github camilamaia / scanapi / tests / unit / tree / test_endpoint_node.py View on Github external
def test_when_parent_has_no_headers(self):
            headers = {"abc": "def"}
            node = EndpointNode(
                {"headers": headers, "name": "node", "requests": []},
                parent=EndpointNode({"name": "parent-node", "requests": []}),
            )
            assert node.headers == headers
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 / tree / test_request_node.py View on Github external
def test_when_endpoint_has_no_params(self):
            params = {"abc": "def"}
            request = RequestNode(
                {"params": params, "path": "http://foo.com", "name": "foo"},
                endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
            )
            assert request.params == params
github camilamaia / scanapi / tests / unit / tree / test_endpoint_node.py View on Github external
def test_when_parent_has_no_url(self):
            base_path = "http://foo.com"
            node = EndpointNode(
                {"path": base_path, "name": "child-node", "requests": []},
                parent=EndpointNode({"name": "parent-node", "requests": []}),
            )
            assert node.path == base_path
github camilamaia / scanapi / tests / unit / tree / test_request_node.py View on Github external
def test_when_request_has_no_method(self):
            request = RequestNode(
                {"name": "foo", "path": "http:foo.com"},
                endpoint=EndpointNode({"name": "foo", "requests": [{}]}),
            )
            assert request.http_method == "GET"
github camilamaia / scanapi / tests / unit / tree / test_request_node.py View on Github external
def test_with_trailing_slashes(self):
            endpoint = EndpointNode(
                {"name": "foo", "requests": [{}], "path": "http://foo.com/"}
            )
            request = RequestNode({"name": "foo", "path": "/foo/"}, endpoint=endpoint)
            assert request.full_url_path == "http://foo.com/foo/"
github camilamaia / scanapi / tests / unit / tree / test_request_node.py View on Github external
def test_when_request_has_name(self):
            request = RequestNode(
                {"name": "list-users", "path": "http:foo.com"},
                endpoint=EndpointNode({"name": "foo", "requests": []}),
            )
            assert request.name == "list-users"
github camilamaia / scanapi / tests / unit / tree / test_endpoint_node.py View on Github external
def test_when_parent_has_url(self):
            base_path = "http://foo.com/api"
            parent = EndpointNode(
                {"path": base_path, "name": "parent-node", "requests": []}
            )
            node = EndpointNode(
                {"path": "/foo", "name": "node", "requests": []}, parent=parent
            )
            assert node.path == f"http://foo.com/api/foo"