Esempio n. 1
0
def test_execute_success_no_output(mock_popen: MockerFixture) -> None:
    """It returns success message."""
    mock_popen.return_value.communicate.return_value = (b"", b"")
    response = guc.GitUseCase().execute(["staticdev/omg", "staticdev/omg2"],
                                        "add", (".", ))

    assert bool(response) is True
    assert response.value == "omg: success.\nomg2: success.\n"
Esempio n. 2
0
def test_execute_success(mock_popen: MockerFixture) -> None:
    """It returns success messages."""
    response = guc.GitUseCase().execute(["staticdev/omg", "staticdev/omg2"],
                                        "checkout", ("xx", ))

    assert bool(response) is True
    assert (
        response.value ==
        "omg: checked out successfully.\nomg2: checked out successfully.\n")
Esempio n. 3
0
def test_execute_git_not_installed(mock_popen: MockerFixture) -> None:
    """It returns failure with git not installed message."""
    mock_popen.side_effect = FileNotFoundError
    response = guc.GitUseCase().execute(["staticdev/notcloned"], "checkout",
                                        ("xx", ))

    assert bool(response) is False
    assert (
        "This command requires Git executable installed and on system path." ==
        response.value["message"])
Esempio n. 4
0
def test_execute_no_folder(mocker: MockerFixture,
                           mock_popen: MockerFixture) -> None:
    """It returns that file does not exist."""
    mock_popen.side_effect = [
        mocker.Mock(),
        FileNotFoundError("No such file or directory"),
    ]
    response = guc.GitUseCase().execute(["staticdev/notcloned"], "checkout",
                                        ("xx", ))

    assert bool(response) is True
    assert response.value == "notcloned: No such file or directory\n"
Esempio n. 5
0
def test_execute_error_during_execution(mock_popen: MockerFixture) -> None:
    """It returns success message with the error on output."""
    mock_popen().communicate.return_value = (
        b"",
        b"error: pathspec 'xyz' did not match any file(s) known to git",
    )
    response = guc.GitUseCase().execute(["staticdev/notcloned"], "checkout",
                                        ("xyz", ))

    assert bool(response) is True
    assert (
        response.value ==
        "notcloned: error: pathspec 'xyz' did not match any file(s) known to git"
    )
Esempio n. 6
0
def commit(
        args: Tuple[str]) -> Union[res.ResponseFailure, res.ResponseSuccess]:
    """Batch `git commit` command."""
    return guc.GitUseCase().execute(
        CONFIG_MANAGER.config.github_selected_repos, "commit", args)