def test_perform_mypy_check_custom_opts_multiple_files(mocker):
    mocker.patch(
        "app.mypy_adapter.get_repo_configuration",
        return_value=RepoOpts(starting_points=["urls.py", "main.py"], additional_mypy_opts="--mock-flag"),
    )
    subprocess_mock = mocker.patch("app.mypy_adapter.subprocess.run")
    subprocess_mock.return_value.stdout = b"mock\nlines\n"

    result = perform_mypy_check("mock-repo")

    assert result == {"mock", "lines"}
    assert " ".join(subprocess_mock.call_args[0][0]) == "mypy --mock-flag urls.py main.py"
    assert subprocess_mock.call_args[1]["cwd"] == "./mock-repo"
Esempio n. 2
0
def test_repo_opts_custom_values():
    custom_values = {"starting_points": ["1", "2"], "additional_mypy_opts": "--mock-flag"}
    opts = RepoOpts(**custom_values)

    assert opts.starting_points == custom_values["starting_points"]
    assert opts.additional_mypy_opts == custom_values["additional_mypy_opts"]
Esempio n. 3
0
def test_pyproject_toml_valid_section(mocker):
    mocker.patch("app.config.toml.load", return_value={"tool": {"mypy-bot": {"additional_mypy_opts": "--mock-flag"}}})
    assert get_repo_configuration("mock_repo") == RepoOpts(additional_mypy_opts="--mock-flag")
Esempio n. 4
0
def test_repo_opts_default_values():
    opts = RepoOpts()
    assert opts.starting_points == ["."]
    assert opts.additional_mypy_opts == ""
Esempio n. 5
0
def test_pyproject_toml_bogus_values(mocker):
    mocker.patch("app.config.toml.load", return_value={"tool": {"mypy-bot": {"random": "value"}}})
    assert get_repo_configuration("mock_repo") == RepoOpts()
Esempio n. 6
0
def test_pyproject_toml_loaded_no_mypy_bot_section(mocker):
    mocker.patch("app.config.toml.load", return_value={"mock": "config"})
    assert get_repo_configuration("mock_repo") == RepoOpts()
Esempio n. 7
0
def test_pyproject_toml_not_found():
    assert get_repo_configuration("mock_repo") == RepoOpts()