def test_git_commit_list_has_expected_commit_list(mocker, mock_process): commit_list = ['another commit', 'initial commit'] mock_process.call.return_value = ("\n".join(commit_list), 'no error') cmd = ['git', 'log', '--reverse', '--pretty=format:%s'] repo = Repository('path') commits = repo.commit_list() assert len(repo.commit_list()) == len(commits) mock_process.call.assert_any_call(cmd, cwd=repo.path)
def test_git_commit_list_has_expected_commit_list(mocker, mock_process): commit_list = [ 'another commit', 'initial commit' ] mock_process.call.return_value = ("\n".join(commit_list), 'no error') cmd = ['git', 'log', '--reverse', '--pretty=format:%s'] repo = Repository('path') commits = repo.commit_list() assert len(repo.commit_list()) == len(commits) mock_process.call.assert_any_call(cmd, cwd=repo.path)
def test_git_commit_list_has_expected_reversed_commits_with_index(mocker): MockRepo = mocker.patch('passpie.history.Repo') mock_repo = MockRepo() commits = ['another commit', 'initial commit'] mock_repo.iter_commits.return_value = commits path = 'some_path' git = Repository(path) commit_list = git.commit_list() assert len(commit_list) == len(commits) assert [i for i, _ in commit_list ] == list(reversed(list(range(len(commits)))))
def test_git_commit_list_has_expected_reversed_commits_with_index(mocker): MockRepo = mocker.patch('passpie.history.Repo') mock_repo = MockRepo() commits = [ 'another commit', 'initial commit' ] mock_repo.iter_commits.return_value = commits path = 'some_path' git = Repository(path) commit_list = git.commit_list() assert len(commit_list) == len(commits) assert [i for i, _ in commit_list] == list(reversed(list(range(len(commits)))))