How to use the scanapi.evaluators.CodeEvaluator.evaluate 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 / evaluators / test_code_evaluator.py View on Github external
def test_should_raises_invalid_python_code_error(self):
                        with pytest.raises(InvalidPythonCodeError) as excinfo:
                            CodeEvaluator.evaluate(
                                "${{response.url == 'abc'}}", {}, is_a_test_case=True
                            )

                        assert (
                            str(excinfo.value)
                            == "Invalid Python code defined in the API spec. "
                            "Exception: 'NoneType' object has no attribute 'url'. "
github camilamaia / scanapi / tests / unit / evaluators / test_code_evaluator.py View on Github external
def test_should_return_assert_results(self, sequence, expected):
                    assert (
                        CodeEvaluator.evaluate(sequence, {}, is_a_test_case=True)
                        == expected
                    )
github camilamaia / scanapi / tests / unit / evaluators / test_code_evaluator.py View on Github external
def test_should_raises_invalid_python_code_error(self):
                        with pytest.raises(InvalidPythonCodeError) as excinfo:
                            CodeEvaluator.evaluate("${{1/0}}", {})

                        assert (
                            str(excinfo.value)
                            == "Invalid Python code defined in the API spec. "
                            "Exception: division by zero. Code: 1/0."
github camilamaia / scanapi / tests / unit / evaluators / test_code_evaluator.py View on Github external
def test_should_return_sequence(self, sequence):
                assert CodeEvaluator.evaluate(sequence, {}) == sequence
github camilamaia / scanapi / tests / unit / evaluators / test_code_evaluator.py View on Github external
def test_should_return_assert_results(
                        self, sequence, expected, response
                    ):
                        assert (
                            CodeEvaluator.evaluate(
                                sequence, {"response": response}, is_a_test_case=True
                            )
                            == expected
                        )
github camilamaia / scanapi / tests / unit / evaluators / test_code_evaluator.py View on Github external
def test_should_return_evaluated_code(self, sequence, expected):
                    assert CodeEvaluator.evaluate(sequence, {}) == expected