本文整理汇总了Python中passpie.history.Repository类的典型用法代码示例。如果您正苦于以下问题:Python Repository类的具体用法?Python Repository怎么用?Python Repository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Repository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_git_init_creates_a_repository_on_path
def test_git_init_creates_a_repository_on_path(mocker, mock_process):
path = 'some_path'
cmd = ['git', 'init', path]
repo = Repository(path)
repo.init()
mock_process.call.assert_called_once_with(cmd)
示例2: test_git_commit_calls_push_when_autopush_set
def test_git_commit_calls_push_when_autopush_set(mocker, mock_process):
message = 'Initial commit'
cmd = ['git', 'commit', '-m', message]
repo = Repository('path', autopush=['origin', 'master'])
mocker.patch.object(repo, 'push')
repo.commit(message)
assert repo.push.called
示例3: test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found
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
示例4: test_git_sha_list_has_call_with_expected_command
def test_git_sha_list_has_call_with_expected_command(mocker, mock_process):
output = 'a\nb'
mock_process.call.return_value = (output, '')
cmd = ['git', 'log', '--reverse', '--pretty=format:%h']
repo = Repository('path')
result = repo.sha_list()
assert result == output.splitlines()
mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
示例5: test_git_commit_creates_commit_with_message
def test_git_commit_creates_commit_with_message(mocker, mock_process):
message = 'Initial commit'
cmd = ['git', 'commit', '-m', message]
repo = Repository('path')
mocker.patch.object(repo, 'add')
repo.commit(message)
repo.add.assert_called_once_with(all=True)
mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
示例6: test_git_commit_creates_commit_with_message
def test_git_commit_creates_commit_with_message(mocker):
MockRepo = mocker.patch('passpie.history.Repo')
path = 'some_path'
message = 'Initial commit'
git = Repository(path)
git.commit(message)
MockRepo().git.add.assert_called_once_with(all=True)
MockRepo().index.commit.assert_called_once_with(message)
示例7: test_commit_by_index_returns_none_when_index_not_found
def test_commit_by_index_returns_none_when_index_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.commit_by_index(index)
assert commit is None
示例8: test_reset_doesnt_call_git_reset_hard_on_commit_when_not_found
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
示例9: test_commit_by_index_returns_found_commit_when_index_exists
def test_commit_by_index_returns_found_commit_when_index_exists(mocker):
MockRepo = mocker.patch('passpie.history.Repo')
mock_repo = MockRepo()
commits = ['initial commit']
mock_repo.iter_commits.return_value = commits
index = 0
git = Repository('path')
commit = git.commit_by_index(index)
assert commit == commits[0]
示例10: test_reset_call_git_reset_hard_on_commit_when_found
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)
示例11: test_git_commit_list_has_expected_commit_list
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)
示例12: test_reset_call_git_reset_hard_on_commit_when_found
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)
示例13: test_git_commit_list_has_expected_reversed_commits_with_index
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)))))
示例14: test_git_push_calls_expected_command_when_remote_branch_is_passed
def test_git_push_calls_expected_command_when_remote_branch_is_passed(mocker, mock_process):
cmd = ['git', 'push', 'another_origin', 'another_branch']
repo = Repository('path')
repo.push(remote='another_origin', branch='another_branch')
mock_process.call.assert_called_once_with(cmd, cwd=repo.path)
示例15: test_git_push_calls_expected_command
def test_git_push_calls_expected_command(mocker, mock_process):
cmd = ['git', 'push', 'origin', 'master']
repo = Repository('path')
repo.push()
mock_process.call.assert_called_once_with(cmd, cwd=repo.path)