repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
zwicker-group/py-pde
import itertools import pytest from pde import UnitGrid, config from pde.grids.boundaries.axes import ( BCDataError, BoundariesBase, BoundariesList, ) from pde.grids.boundaries.axis import get_boundary_axis from pde.grids.boundaries.local import NeumannBC def test_boundaries_legacy(): """Test setting...
2
assert
numeric_literal
tests/grids/boundaries/test_axes_boundaries_legacy.py
test_boundaries_legacy
31
null
scanapi/scanapi
import errno import logging import os import requests import yaml from pytest import fixture, mark, raises from scanapi.errors import EmptyConfigFileError, InvalidKeyError from scanapi.scan import scan log = logging.getLogger(__name__) def file_not_found(*args, **kwargs): raise FileNotFoundError( errno....
4
assert
numeric_literal
tests/unit/test_scan.py
test_should_log_error
TestScan
61
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode class TestPath: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.tree.endpoint_node.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func @mark.context("whe...
base_path
assert
variable
tests/unit/tree/endpoint_node/test_path.py
test_when_parent_has_no_url
TestPath
26
null
scanapi/scanapi
import requests from pytest import fixture, mark, raises from scanapi.errors import InvalidKeyError, MissingMandatoryKeyError from scanapi.utils import join_urls, session_with_retry, validate_keys def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.c...
0
assert
numeric_literal
tests/unit/test_utils.py
test_should_not_mount_custom_adapters
TestSessionWithRetry
118
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestParams: @mark.context("when parent spec has no params attribute defined") @mark.it("should set params attribute the same as the node's one") def test_when_parent_has_no_params(self): params = {"abc": "def"} node = Endp...
params
assert
variable
tests/unit/tree/endpoint_node/test_params.py
test_when_parent_has_no_params
TestParams
17
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestFullPathUrl: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_f...
"http://foo.com/foo/"
assert
string_literal
tests/unit/tree/request_node/test_full_path_url.py
test_with_trailing_slashes
TestFullPathUrl
58
null
scanapi/scanapi
from pytest import mark, raises from scanapi.config_loader import load_config_file from scanapi.errors import BadConfigIncludeError, EmptyConfigFileError class TestLoadConfigFile: @mark.context("file does not exist") @mark.it("should raise an exception") def test_should_raise_exception(self): wi...
"[Errno 2] No such file or directory: 'invalid/path.yaml'"
assert
string_literal
tests/unit/test_config_loader.py
test_should_raise_exception
TestLoadConfigFile
45
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestDelay: @mark.context("when both node and parent specs have a delay defined") @mark.it("should set delay attribute the same as the node's one") def test_when_both_node_and_parent_have_delay(self): node = EndpointNode( ...
3
assert
numeric_literal
tests/unit/tree/endpoint_node/test_delay.py
test_when_both_node_and_parent_have_delay
TestDelay
37
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode, tree_keys class TestValidate: def mock_validate_keys(self, mocker): return mocker.patch("scanapi.tree.request_node.validate_keys") @mark.it("should call the validate_keys method") def test_should_call_validate_k...
"request")
assert_*
string_literal
tests/unit/tree/request_node/test_validate.py
test_should_call_validate_keys
TestValidate
26
null
scanapi/scanapi
import errno import logging import os import requests import yaml from pytest import fixture, mark, raises from scanapi.errors import EmptyConfigFileError, InvalidKeyError from scanapi.scan import scan log = logging.getLogger(__name__) def file_not_found(*args, **kwargs): raise FileNotFoundError( errno....
SystemExit
assert
variable
tests/unit/test_scan.py
test_should_log_error
TestScan
60
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, tree_keys class TestValidate: def mock_validate_keys(self, mocker): return mocker.patch("scanapi.tree.endpoint_node.validate_keys") @mark.it("should call the validate_keys method") def test_should_call_validate_keys(self, mo...
"endpoint")
assert_*
string_literal
tests/unit/tree/endpoint_node/test_validate.py
test_should_call_validate_keys
TestValidate
25
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import InvalidKeyError from scanapi.tree import EndpointNode class TestOptions: @mark.context("when parent spec has options defined") @mark.it("should append parent options") def test_when_parent_has_name(self): parent_options = {"timeout": 1.0}...
{**parent_options, **child_options}
assert
collection
tests/unit/tree/endpoint_node/test_options.py
test_when_parent_has_name
TestOptions
33
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode, TestingNode class TestFullName: @mark.it( "should set the full_name attribute as the concatanation of the parents' names separated by ::" ) def test_full_name(self): endpoint_node = EndpointNode({"name": "foo"}) ...
"foo::bar::lol"
assert
string_literal
tests/unit/tree/testing_node/test_full_name.py
test_full_name
TestFullName
19
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestGetSpecs: @mark.context("when child has the requested spec but parent does not") @mark.it("should return child spec") def test_when_child_has_spec(self): spec = { "headers": {"child_foo": "child_bar"}, ...
{"child_foo": "child_bar"}
assert
collection
tests/unit/tree/endpoint_node/test_get_specs.py
test_when_child_has_spec
TestGetSpecs
75
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.errors import InvalidKeyError from scanapi.tree import EndpointNode, RequestNode class TestOptions: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.tree.request_node.SpecEvaluator.evaluate" ) mock_func.r...
request_options
assert
variable
tests/unit/tree/request_node/test_options.py
test_when_request_and_endpoint_has_options
TestOptions
49
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
[ mocker.call("foo", spec_evaluator, False), mocker.call("bar", spec_evaluator, False), ])
assert_*
collection
tests/unit/evaluators/test_spec_evaluator.py
test_return_evaluated_dict
TestEvaluateDict
146
null
scanapi/scanapi
import requests from pytest import fixture, mark, raises from scanapi.errors import InvalidPythonCodeError from scanapi.evaluators import CodeEvaluator class TestSideEffects: @mark.context("when evaluating multiple expressions") @mark.it("should be isolated from each other") def test_evaluation_isolation...
"2"
assert
string_literal
tests/unit/evaluators/test_code_evaluator.py
test_evaluation_isolation
TestSideEffects
257
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestPropagateSpecVars: test_data = [ ({"spec_var": "value"}, None, {"spec_var": "value"}), ( {"spec_var": "${{ response }}"}, {"response": "value"}, {"spec_var": "value"}, ), ] ...
{**parent_vars, **existing_node_var}
assert
collection
tests/unit/tree/endpoint_node/test_propagate_spec_vars.py
test_var_with_existing_name
TestPropagateSpecVars
47
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode class TestInit: @mark.context("when required keys are missing") @mark.it("should raise missing mandatory key error") def test_missing_required_keys(self): with raises(MissingM...
"Missing 'name' key(s) at 'endpoint' scope"
assert
string_literal
tests/unit/tree/endpoint_node/test_init.py
test_missing_required_keys
TestInit
33
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
0
assert
numeric_literal
tests/unit/evaluators/test_spec_evaluator.py
test_return_empty_dict
TestEvaluateDict
133
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.com") class TestOverrideInfo: @mark.it("should skip when body is None...
None
assert
none_literal
tests/unit/test_hide_utils.py
test_skip_when_body_is_none
TestOverrideInfo
184
null
scanapi/scanapi
import pathlib from freezegun.api import FakeDatetime from pytest import fixture, mark from scanapi.reporter import Reporter fake_results = [ {"response": "foo", "tests_results": [], "no_failure": True}, {"response": "bar", "tests_results": [], "no_failure": False}, ] def mock_version(mocker): return mo...
"2.0.0"
assert
string_literal
tests/unit/test_reporter.py
test_build_context_with_version
TestBuildContext
175
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestParams: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func ...
params
assert
variable
tests/unit/tree/request_node/test_params.py
test_when_endpoint_has_no_params
TestParams
26
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.template_render import _loader, render, render_body class TestLoader: @mark.context("when it is external") @mark.it("should return file system loader") def test_return_file_system_loader(self): loader = _loader(True) assert lo...
"FileSystemLoader"
assert
string_literal
tests/unit/test_template_render.py
test_return_file_system_loader
TestLoader
68
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode, RequestNode class TestName: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.tree.request_node.SpecEvaluator.evaluate" ) mock_...
"Missing 'name' key(s) at 'request' scope"
assert
string_literal
tests/unit/tree/request_node/test_name.py
test_when_request_has_no_name
TestName
35
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestGetSpecs: @mark.context("when both parent and child do not have the requested spec") @mark.it("should return an empty dictionary") def test_when_there_is_no_spec(self): spec = {"name": "node", "requests": []} parent ...
{}
assert
collection
tests/unit/tree/endpoint_node/test_get_specs.py
test_when_there_is_no_spec
TestGetSpecs
91
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
False)
assert_*
bool_literal
tests/unit/evaluators/test_spec_evaluator.py
test_should_call_evaluate_string
TestEvaluateString
109
null
scanapi/scanapi
from random import randrange from pytest import mark, raises from scanapi.session import Session class TestIncrementSuccesses: @mark.it("should increment successes") def test_increment(self): session = Session() times = randrange(1, 10) for _ in range(times): session.incr...
times
assert
variable
tests/unit/test_session.py
test_increment
TestIncrementSuccesses
76
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestHeaders: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func ...
headers
assert
variable
tests/unit/tree/request_node/test_headers.py
test_when_endpoint_has_no_headers
TestHeaders
26
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode, RequestNode class TestInit: @mark.context("when required keys are missing") @mark.it("should raise missing mandatory key error") def test_missing_required_keys(self): with ra...
"Missing 'name' key(s) at 'request' scope"
assert
string_literal
tests/unit/tree/request_node/test_init.py
test_missing_required_keys
TestInit
28
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import HTTPMethodNotAllowedError from scanapi.tree import EndpointNode, RequestNode class TestHTTPMethod: @mark.context("when request spec has no http method defined") @mark.it("should set the http_method attribute as get") def test_when_request_has_no_...
"GET"
assert
string_literal
tests/unit/tree/request_node/test_http_method.py
test_when_request_has_no_method
TestHTTPMethod
26
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestGetAllVars: @mark.it("should return spec_var values from the node and all parents") def test_get_all_vars(self): grandparent = EndpointNode({"name": "grandparent"}) grandparent_key = "grandparent_key" grandparent_v...
{ grandparent_key: grandparent_value, parent_key: parent_value, node_key: node_value, }
assert
collection
tests/unit/tree/endpoint_node/test_get_all_vars.py
test_get_all_vars
TestGetAllVars
26
null
scanapi/scanapi
from datetime import timedelta from unittest.mock import MagicMock from pytest import fixture, mark from scanapi.console import ( write_report_path, write_result, write_results, write_summary, ) def mocked__console(mocker): return mocker.patch("scanapi.console.console") class TestWriteResult: ...
calls)
assert_*
variable
tests/unit/test_console.py
test_write_failures
TestWriteResult
100
null
scanapi/scanapi
import errno import logging import os import requests import yaml from pytest import fixture, mark, raises from scanapi.errors import EmptyConfigFileError, InvalidKeyError from scanapi.scan import scan log = logging.getLogger(__name__) def file_not_found(*args, **kwargs): raise FileNotFoundError( errno....
caplog.text
assert
complex_expr
tests/unit/test_scan.py
test_should_log_error
TestScan
63
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.settings import settings def mock_load_config_file(mocker): return mocker.patch("scanapi.settings.load_config_file") def mock_has_local_config_file(mocker): return mocker.patch( "scanapi.settings.Settings.has_local_config_file", mocker.Pro...
"./scanapi.conf")
assert_*
string_literal
tests/unit/test_settings.py
test_should_save_preferences_2
TestSaveConfigFilePreferences
85
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestBody: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func ...
None
assert
none_literal
tests/unit/tree/request_node/test_body.py
test_when_request_has_no_body
TestBody
25
null
scanapi/scanapi
import logging from pytest import fixture, mark from httpx import HTTPError from scanapi.exit_code import ExitCode from scanapi.tree import EndpointNode log = logging.getLogger(__name__) class TestRun: def mock_run_request(self, mocker): return mocker.patch("scanapi.tree.request_node.RequestNode.run") ...
caplog.text
assert
complex_expr
tests/unit/tree/endpoint_node/test_run.py
test_when_request_fails
TestRun
99
null
scanapi/scanapi
import requests from pytest import fixture, mark, raises from scanapi.errors import InvalidPythonCodeError from scanapi.evaluators import CodeEvaluator class TestEvaluate: def response(self, requests_mock): requests_mock.get("http://test.com", text="abcde") return requests.get("http://test.com") ...
expected
assert
variable
tests/unit/evaluators/test_code_evaluator.py
test_should_return_assert_results
TestEvaluate
35
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.settings import settings def mock_load_config_file(mocker): return mocker.patch("scanapi.settings.load_config_file") def mock_has_local_config_file(mocker): return mocker.patch( "scanapi.settings.Settings.has_local_config_file", mocker.Pro...
"[Errno 2] No such file or directory: 'invalid/my_config_file.yaml'"
assert
string_literal
tests/unit/test_settings.py
test_should_raise_exception
TestSaveConfigFilePreferences
72
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode class TestDelay: @mark.context("when request spec has a delay defined") @mark.it("should set delay attribute accordingly") def test_when_request_has_delay(self): request = RequestNode( {"name": "foo", "delay": ...
1
assert
numeric_literal
tests/unit/tree/request_node/test_delay.py
test_when_request_has_delay
TestDelay
24
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode class TestRepr: @mark.context("when path is not defined") @mark.it("should return <RequestNode >") def test_when_path_is_not_defined(self): endpoint = EndpointNode({"name": "foo", "requests": [{}]}) request = Reques...
"<RequestNode >"
assert
string_literal
tests/unit/tree/request_node/test_repr.py
test_when_path_is_not_defined
TestRepr
14
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
["foo", "bar"]
assert
collection
tests/unit/evaluators/test_spec_evaluator.py
test_return_evaluated_list
TestEvaluateList
170
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode class TestPath: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.tree.endpoint_node.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func @mark.context( ...
"http://foo.com/foo/"
assert
string_literal
tests/unit/tree/endpoint_node/test_path.py
test_with_trailing_slashes
TestPath
59
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestRun: def mock_session_with_retry(self, mocker): return mocker.patch("scanapi.tree.request_node.session_with_retry") def mock_run_tests(self, mocker): return mocker.patch("scanapi.tree.request_node.R...
1
assert
numeric_literal
tests/unit/tree/request_node/test_run.py
test_calls_write_result
TestRun
194
null
scanapi/scanapi
from datetime import timedelta from unittest.mock import MagicMock from pytest import fixture, mark from scanapi.console import ( write_report_path, write_result, write_results, write_summary, ) def mocked__console(mocker): return mocker.patch("scanapi.console.console") class TestWriteResults: ...
3
assert
numeric_literal
tests/unit/test_console.py
test_should_call_3_times
TestWriteResults
38
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode class TestRepr: @mark.context("when both request and endpoint paths are defined") @mark.it("should return <RequestNode endpoint_path/request_path>") def test_when_request_and_endpoint_paths_are_defined(self): base_path = "...
"<RequestNode http://foo.com/api/foo/bar/>"
assert
string_literal
tests/unit/tree/request_node/test_repr.py
test_when_request_and_endpoint_paths_are_defined
TestRepr
53
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestParams: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func ...
{"abc": "def", "xxx": "www"}
assert
collection
tests/unit/tree/request_node/test_params.py
test_when_endpoint_has_params
TestParams
48
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode, TestingNode class TestRun: def testing_node(self): endpoint_node = EndpointNode(spec={"name": "foo"}) request_node = RequestNode(spec={"name": "bar"}, endpoint=endpoint_node) spec = { "name": ...
{ "name": "foo::bar::status_is_200", "status": "passed", "failure": None, "error": None, }
assert
collection
tests/unit/tree/testing_node/test_run.py
test_build_result
TestRun
47
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.com") class TestOverrideInfo: @mark.it("should overrides body") d...
b'{"id": "SENSITIVE_INFORMATION", "name": "Tarik", "yearsOfExperience": 2}'
assert
string_literal
tests/unit/test_hide_utils.py
test_overrides_body
TestOverrideInfo
143
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode class TestRepr: @mark.context("when request node path is defined") @mark.it("should return <RequestNode request_path>") def test_when_request_node_path_is_defined(self): endpoint = EndpointNode({"name": "foo", "requests": ...
"<RequestNode /bar/>"
assert
string_literal
tests/unit/tree/request_node/test_repr.py
test_when_request_node_path_is_defined
TestRepr
37
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode, RequestNode class TestName: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.tree.request_node.SpecEvaluator.evaluate" ) mock_...
"list-users"
assert
string_literal
tests/unit/tree/request_node/test_name.py
test_when_request_has_name
TestName
26
null
scanapi/scanapi
import errno import logging import os import requests import yaml from pytest import fixture, mark, raises from scanapi.errors import EmptyConfigFileError, InvalidKeyError from scanapi.scan import scan log = logging.getLogger(__name__) def file_not_found(*args, **kwargs): raise FileNotFoundError( errno....
0
assert
numeric_literal
tests/unit/test_scan.py
test_should_call_reporter_write_call_console_write_summary_and_exit
TestScan
157
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode, TestingNode class TestRun: def testing_node(self): endpoint_node = EndpointNode(spec={"name": "foo"}) request_node = RequestNode(spec={"name": "bar"}, endpoint=endpoint_node) spec = { "name": ...
1
assert
numeric_literal
tests/unit/tree/testing_node/test_run.py
test_increment_successes
TestRun
66
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestRepr: @mark.context("when parent spec has a name defined") @mark.it("should return <EndpointNode root::child-node>") def test_when_parent_has_name(self): parent = EndpointNode({"name": "root"}) node = EndpointNode({"n...
"<EndpointNode root::child-node>"
assert
string_literal
tests/unit/tree/endpoint_node/test_repr.py
test_when_parent_has_name
TestRepr
20
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestHeaders: @mark.context("when parent spec has no headers attribute defined") @mark.it("should set headers attribute the same as the node's one") def test_when_parent_has_no_headers(self): headers = {"abc": "def"} node =...
headers
assert
variable
tests/unit/tree/endpoint_node/test_headers.py
test_when_parent_has_no_headers
TestHeaders
17
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestRun: def mock_session_with_retry(self, mocker): return mocker.patch("scanapi.tree.request_node.session_with_retry") def mock_run_tests(self, mocker): return mocker.patch("scanapi.tree.request_node.R...
0.001)
assert_*
numeric_literal
tests/unit/tree/request_node/test_run.py
test_calls_request
TestRun
49
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import HTTPMethodNotAllowedError from scanapi.tree import EndpointNode, RequestNode class TestHTTPMethod: @mark.context("when request spec has and invalid http method defined") @mark.it("should raise http method not allowed error") def test_when_method_...
expected
assert
variable
tests/unit/tree/request_node/test_http_method.py
test_when_method_is_invalid
TestHTTPMethod
42
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
"global_value"
assert
string_literal
tests/unit/evaluators/test_spec_evaluator.py
test_should_return_from_global_vars
TestGet
51
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.com") class TestOverrideInfo: @mark.it("should overrides url") def...
"http://test.com/users/SENSITIVE_INFORMATION/details"
assert
string_literal
tests/unit/test_hide_utils.py
test_overrides_url
TestOverrideInfo
102
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.settings import settings def mock_load_config_file(mocker): return mocker.patch("scanapi.settings.load_config_file") def mock_has_local_config_file(mocker): return mocker.patch( "scanapi.settings.Settings.has_local_config_file", mocker.Pro...
True
assert
bool_literal
tests/unit/test_settings.py
test_returns_true
TestHasGlobalConfigFile
172
null
scanapi/scanapi
from random import randrange from pytest import mark, raises from scanapi.session import Session class TestStart: @mark.it("should initialize started_at with current time") @mark.freeze_time("2020-06-15 18:54:57") def test_init_started_at(self): session = Session() assert str(session.st...
"2020-06-15 18:54:57"
assert
string_literal
tests/unit/test_session.py
test_init_started_at
TestStart
43
null
scanapi/scanapi
import requests from pytest import fixture, mark, raises from scanapi.errors import InvalidPythonCodeError from scanapi.evaluators import CodeEvaluator class TestSideEffects: @mark.context("when evaluating multiple expressions") @mark.it("should be isolated from each other") def test_evaluation_isolation...
"1"
assert
string_literal
tests/unit/evaluators/test_code_evaluator.py
test_evaluation_isolation
TestSideEffects
256
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestRun: def mock_session_with_retry(self, mocker): return mocker.patch("scanapi.tree.request_node.session_with_retry") def mock_run_tests(self, mocker): return mocker.patch("scanapi.tree.request_node.R...
{ "response": mock_session_with_retry().__enter__().request(), "tests_results": [], "no_failure": True, "request_node_name": "request_name", "options": {"timeout": 2.3, "verify": False}, }
assert
collection
tests/unit/tree/request_node/test_run.py
test_calls_request
TestRun
61
null
scanapi/scanapi
import logging import yaml from click.testing import CliRunner from pytest import mark from scanapi.cli import run log = logging.getLogger(__name__) runner = CliRunner() def yaml_error(*args, **kwargs): raise yaml.YAMLError("error foo") class TestRun: @mark.context("when nothing wrong happens") @mark.i...
4
assert
numeric_literal
tests/unit/test_main.py
test_call_save_preferences
TestRun
28
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode, RequestNode class TestInit: @mark.context("when there are no mandatory keys missing") @mark.it("should set endpoint and spec attributes accordingly") def test_init_spec_and_endpoint(s...
{"name": "bar"}
assert
collection
tests/unit/tree/request_node/test_init.py
test_init_spec_and_endpoint
TestInit
17
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
1
assert
numeric_literal
tests/unit/evaluators/test_spec_evaluator.py
test_should_call_evaluate_string
TestEvaluateString
108
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode class TestParams: def mock_evaluate(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.spec_evaluator.SpecEvaluator.evaluate" ) mock_func.return_value = "" return mock_func ...
calls)
assert_*
variable
tests/unit/tree/request_node/test_params.py
test_calls_evaluate
TestParams
91
null
scanapi/scanapi
import requests from pytest import fixture, mark, raises from scanapi.errors import InvalidKeyError, MissingMandatoryKeyError from scanapi.utils import join_urls, session_with_retry, validate_keys def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.c...
expected
assert
variable
tests/unit/test_utils.py
test_build_url_properly
TestJoinUrls
64
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestGetRequests: @mark.context("when node has children") @mark.it("should return the requests") def test_when_node_has_children(self): node = EndpointNode( { "endpoints": [ { ...
2
assert
numeric_literal
tests/unit/tree/endpoint_node/test_get_requests.py
test_when_node_has_children
TestGetRequests
34
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestName: @mark.context("when parent spec has no name defined") @mark.it("should set child node's name") def test_when_parent_has_no_name(self): node = EndpointNode({"name": "child-node"}, parent=EndpointNode({})) assert ...
"child-node"
assert
string_literal
tests/unit/tree/endpoint_node/test_name.py
test_when_parent_has_no_name
TestName
13
null
scanapi/scanapi
import pathlib from freezegun.api import FakeDatetime from pytest import fixture, mark from scanapi.reporter import Reporter fake_results = [ {"response": "foo", "tests_results": [], "no_failure": True}, {"response": "bar", "tests_results": [], "no_failure": False}, ] def mock_version(mocker): return mo...
True)
assert_*
bool_literal
tests/unit/test_reporter.py
test_should_write_to_custom_output
TestWrite
126
null
scanapi/scanapi
from random import randrange from pytest import mark, raises from scanapi.session import Session class TestExit: @mark.it("should exit with proper error") @mark.parametrize( "failures, errors, error_code", [(0, 0, 0), (1, 0, 1), (0, 1, 2), (1, 1, 2)], ) def test_exit_with_proper_error...
SystemExit
assert
variable
tests/unit/test_session.py
test_exit_with_proper_error
TestExit
61
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode, RequestNode, TestingNode class TestInit: @mark.context("when required keys are missing") @mark.it("should raise missing mandatory key error") def test_missing_required_keys(self): ...
"Missing 'assert', 'name' key(s) at 'test' scope"
assert
string_literal
tests/unit/tree/testing_node/test_init.py
test_missing_required_keys
TestInit
20
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.settings import settings def mock_load_config_file(mocker): return mocker.patch("scanapi.settings.load_config_file") def mock_has_local_config_file(mocker): return mocker.patch( "scanapi.settings.Settings.has_local_config_file", mocker.Pro...
False
assert
bool_literal
tests/unit/test_settings.py
test_returns_false
TestHasGlobalConfigFile
179
null
scanapi/scanapi
import os from pytest import fixture, mark, raises from scanapi.errors import BadConfigurationError from scanapi.evaluators import StringEvaluator class TestEvaluate: def mock__evaluate_env_var(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.string_evaluator.StringEvaluator._eva...
"boo")
assert_*
string_literal
tests/unit/evaluators/test_string_evaluator.py
test_calls__evaluate_env_var
TestEvaluate
36
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode class TestRepr: @mark.context("when endpoint node path is defined") @mark.it("should return <RequestNode endpoint_path>") def test_when_endpoint_path_is_defined(self): base_path = "http://foo.com/api" parent = Endp...
"<RequestNode http://foo.com/api/foo>"
assert
string_literal
tests/unit/tree/request_node/test_repr.py
test_when_endpoint_path_is_defined
TestRepr
28
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode, tree_keys class TestValidate: def mock_validate_keys(self, mocker): return mocker.patch("scanapi.tree.request_node.validate_keys") @mark.it("should call the validate_keys method") def test_should_call_validate_k...
3
assert
numeric_literal
tests/unit/tree/request_node/test_validate.py
test_should_call_validate_keys
TestValidate
44
null
scanapi/scanapi
import pathlib from freezegun.api import FakeDatetime from pytest import fixture, mark from scanapi.reporter import Reporter fake_results = [ {"response": "foo", "tests_results": [], "no_failure": True}, {"response": "bar", "tests_results": [], "no_failure": False}, ] def mock_version(mocker): return mo...
"w")
assert_*
string_literal
tests/unit/test_reporter.py
test_should_write_to_default_output
TestWrite
108
null
scanapi/scanapi
import os from pytest import fixture, mark, raises from scanapi.errors import BadConfigurationError from scanapi.evaluators import StringEvaluator class TestEvaluate: def mock__evaluate_env_var(self, mocker): mock_func = mocker.patch( "scanapi.evaluators.string_evaluator.StringEvaluator._eva...
False)
assert_*
bool_literal
tests/unit/evaluators/test_string_evaluator.py
test_calls_code_evaluate
TestEvaluate
31
null
scanapi/scanapi
import os from pytest import fixture, mark, raises from scanapi.errors import BadConfigurationError from scanapi.evaluators import StringEvaluator class TestEvaluateEnvVar: test_data = [ "no env var", "${var}", "${MyVar}", "${{var}}", "${{VAR}}", ] test_data = [ ...
"'BASE_URL' environment variable not set or badly configured"
assert
string_literal
tests/unit/evaluators/test_string_evaluator.py
test_should_raise_bad_configuration_error
TestEvaluateEnvVar
92
null
scanapi/scanapi
from random import randrange from pytest import mark, raises from scanapi.session import Session class TestSucceed: @mark.parametrize( "failures, errors, expected", [(0, 0, True), (1, 0, False), (0, 1, False), (2, 1, False)], ) @mark.it( "should fail when there is a failure and sh...
expected
assert
variable
tests/unit/test_session.py
test_failed_when_there_is_failure
TestSucceed
32
null
scanapi/scanapi
import pathlib from freezegun.api import FakeDatetime from pytest import fixture, mark from scanapi.reporter import Reporter fake_results = [ {"response": "foo", "tests_results": [], "no_failure": True}, {"response": "bar", "tests_results": [], "no_failure": False}, ] def mock_version(mocker): return mo...
"unknown"
assert
string_literal
tests/unit/test_reporter.py
test_build_context_with_package_not_found
TestBuildContext
197
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.settings import settings def mock_load_config_file(mocker): return mocker.patch("scanapi.settings.load_config_file") def mock_has_local_config_file(mocker): return mocker.patch( "scanapi.settings.Settings.has_local_config_file", mocker.Pro...
None)
assert_*
none_literal
tests/unit/test_settings.py
test_should_pass_config_path_as_none
TestSavePreferences
135
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.template_render import _loader, render, render_body class TestRender: def mocked__get_template(self, mocker): return mocker.patch("scanapi.template_render.Environment.get_template") def mocked__request(self, mocker): return mocker...
render_body(request)
assert
func_call
tests/unit/test_template_render.py
test_should_render_json
TestRender
34
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.evaluators.spec_evaluator import SpecEvaluator from scanapi.tree import EndpointNode def mock_string_evaluate(mocker): return mocker.patch( "scanapi.evaluators.spec_evaluator.StringEvaluator.evaluate" ) def spec_evaluator(): parent = EndpointN...
{"var_2": "foo"}
assert
collection
tests/unit/evaluators/test_spec_evaluator.py
test_should_return_dictionary_without_response_var
TestFilterResponseVar
95
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestPropagateSpecVars: test_data = [ ({"spec_var": "value"}, None, {"spec_var": "value"}), ( {"spec_var": "${{ response }}"}, {"response": "value"}, {"spec_var": "value"}, ), ] ...
expected_result
assert
variable
tests/unit/tree/endpoint_node/test_propagate_spec_vars.py
test_propagate_spec_vars
TestPropagateSpecVars
27
null
scanapi/scanapi
import errno import logging import os import requests import yaml from pytest import fixture, mark, raises from scanapi.errors import EmptyConfigFileError, InvalidKeyError from scanapi.scan import scan log = logging.getLogger(__name__) def file_not_found(*args, **kwargs): raise FileNotFoundError( errno....
[response])
assert_*
collection
tests/unit/test_scan.py
test_should_call_console_write_results_call_console_write_summary_and_exit
TestScan
190
null
scanapi/scanapi
import os from pytest import fixture, mark, raises from scanapi.errors import BadConfigurationError from scanapi.evaluators import StringEvaluator class TestEvaluateEnvVar: test_data = [ "no env var", "${var}", "${MyVar}", "${{var}}", "${{VAR}}", ] @mark.context("...
sequence
assert
variable
tests/unit/evaluators/test_string_evaluator.py
test_should_return_sequence
TestEvaluateEnvVar
54
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import MissingMandatoryKeyError from scanapi.tree import EndpointNode, RequestNode class TestInit: @mark.context("when there are no mandatory keys missing") @mark.it("should set endpoint and spec attributes accordingly") def test_init_spec_and_endpoint(s...
endpoint
assert
variable
tests/unit/tree/request_node/test_init.py
test_init_spec_and_endpoint
TestInit
16
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import InvalidKeyError from scanapi.tree import EndpointNode class TestOptions: @mark.context("when parent and node spec has options defined") @mark.it("should keep node options") def test_when_both_was_same_options(self): parent_options = {"tim...
child_options
assert
variable
tests/unit/tree/endpoint_node/test_options.py
test_when_both_was_same_options
TestOptions
46
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestDelay: @mark.context("when node spec has a delay defined") @mark.it("should set delay attribute accordingly") def test_when_node_has_delay(self): node = EndpointNode({"name": "node", "delay": 1}) assert node.delay ==...
1
assert
numeric_literal
tests/unit/tree/endpoint_node/test_delay.py
test_when_node_has_delay
TestDelay
19
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.com") class TestHideSensitiveInfo: def mock__hide(self, mocker): ...
calls)
assert_*
variable
tests/unit/test_hide_utils.py
test_calls__hide
TestHideSensitiveInfo
57
null
scanapi/scanapi
from pytest import mark, raises from scanapi.errors import InvalidKeyError from scanapi.tree import EndpointNode class TestOptions: @mark.context("when parent spec has no options defined") @mark.it("should have only node options") def test_when_parent_has_no_options(self): options = {"verify": Fal...
options
assert
variable
tests/unit/tree/endpoint_node/test_options.py
test_when_parent_has_no_options
TestOptions
20
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode, RequestNode class TestDelay: @mark.context("when endpoint spec has a delay defined") @mark.it("should set delay attribute the same as the endpoint's one") def test_when_endpoint_has_delay(self): request = RequestNode( {"na...
2
assert
numeric_literal
tests/unit/tree/request_node/test_delay.py
test_when_endpoint_has_delay
TestDelay
33
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, tree_keys class TestValidate: def mock_validate_keys(self, mocker): return mocker.patch("scanapi.tree.endpoint_node.validate_keys") @mark.it("should call the validate_keys method") def test_should_call_validate_keys(self, mo...
4
assert
numeric_literal
tests/unit/tree/endpoint_node/test_validate.py
test_should_call_validate_keys
TestValidate
41
null
scanapi/scanapi
from pytest import fixture, mark, raises from scanapi.settings import settings def mock_load_config_file(mocker): return mocker.patch("scanapi.settings.load_config_file") def mock_has_local_config_file(mocker): return mocker.patch( "scanapi.settings.Settings.has_local_config_file", mocker.Pro...
"scanapi.yaml"
assert
string_literal
tests/unit/test_settings.py
test_should_init_with_default_values
TestInit
40
null
scanapi/scanapi
import requests from pytest import fixture, mark from scanapi.hide_utils import _hide, _override_info, hide_sensitive_info def response(requests_mock): requests_mock.get("http://test.com", text="data") return requests.get("http://test.com") class TestOverrideInfo: @mark.it("should overrides headers") ...
"SENSITIVE_INFORMATION"
assert
string_literal
tests/unit/test_hide_utils.py
test_overrides_headers
TestOverrideInfo
115
null
scanapi/scanapi
from pytest import fixture, mark from scanapi.tree import EndpointNode, RequestNode, TestingNode class TestRun: def testing_node(self): endpoint_node = EndpointNode(spec={"name": "foo"}) request_node = RequestNode(spec={"name": "bar"}, endpoint=endpoint_node) spec = { "name": ...
{ "name": "foo::bar::status_is_200", "status": "failed", "failure": "response.status_code == 200", "error": None, }
assert
collection
tests/unit/tree/testing_node/test_run.py
test_build_result_2
TestRun
82
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestDelay: @mark.context("when node spec has no delay defined") @mark.it("should set delay as 0") def test_when_node_has_no_delay(self): node = EndpointNode({"name": "node"}) assert node.delay ==
0
assert
numeric_literal
tests/unit/tree/endpoint_node/test_delay.py
test_when_node_has_no_delay
TestDelay
13
null
scanapi/scanapi
from pytest import mark from scanapi.tree import EndpointNode class TestName: @mark.context("when parent spec has a name defined") @mark.it("should set parent_name::child_name") def test_when_parent_has_name(self): parent = EndpointNode({"name": "root"}) node = EndpointNode({"name": "chil...
"root::child-node"
assert
string_literal
tests/unit/tree/endpoint_node/test_name.py
test_when_parent_has_name
TestName
20
null