def test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found(mocker, mock_process):
    sha_list = []
    index = 0

    repo = Repository('path')
    mocker.patch.object(repo, 'sha_list', return_value=sha_list)
    repo.reset(index)

    mock_process.call.called is False
Exemple #2
0
def test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found(
        mocker, mock_process):
    sha_list = []
    index = 0

    repo = Repository('path')
    mocker.patch.object(repo, 'sha_list', return_value=sha_list)
    repo.reset(index)

    mock_process.call.called is False
def test_reset_call_git_reset_hard_on_commit_when_found(mocker, mock_process):
    sha_list = [
        'd6b52b5',
        '34c5439',
        '5910c2b',
    ]
    index = 0
    cmd = ['git', 'reset', '--hard', sha_list[index]]

    repo = Repository('path')
    mocker.patch.object(repo, 'sha_list', return_value=sha_list)
    repo.reset(index)

    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
Exemple #4
0
def test_reset_call_git_reset_hard_on_commit_when_found(mocker, mock_process):
    sha_list = [
        'd6b52b5',
        '34c5439',
        '5910c2b',
    ]
    index = 0
    cmd = ['git', 'reset', '--hard', sha_list[index]]

    repo = Repository('path')
    mocker.patch.object(repo, 'sha_list', return_value=sha_list)
    repo.reset(index)

    mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
Exemple #5
0
def test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = []
    mock_repo.iter_commits.return_value = commits
    index = len(commits) + 1

    git = Repository('path')
    commit = git.reset(index)

    assert mock_repo.git.reset.called is False
Exemple #6
0
def test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = []
    mock_repo.iter_commits.return_value = commits
    index = len(commits) + 1

    git = Repository('path')
    commit = git.reset(index)

    assert mock_repo.git.reset.called is False
Exemple #7
0
def test_reset_call_git_reset_hard_on_commit_when_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = [MagicMock()]
    mock_repo.iter_commits.return_value = commits
    index = 0

    git = Repository('path')
    commit = git.reset(index)

    assert mock_repo.git.reset.called is True
    mock_repo.git.reset.assert_called_once_with('--hard', commits[0].hexsha)
Exemple #8
0
def test_reset_call_git_reset_hard_on_commit_when_found(mocker):
    MockRepo = mocker.patch('passpie.history.Repo')
    mock_repo = MockRepo()
    commits = [MagicMock()]
    mock_repo.iter_commits.return_value = commits
    index = 0

    git = Repository('path')
    commit = git.reset(index)

    assert mock_repo.git.reset.called is True
    mock_repo.git.reset.assert_called_once_with('--hard', commits[0].hexsha)