Exemplo n.º 1
0
def test_git_run_uses_provided_git_root():
    with patch_utils('check_call') as check_call:
        git = Git('/usr/bin/git', '/some/dufl/root')
        check_call.return_value = 0
        git.run('pull')
        assert check_call.call_args[0][0][1] == '-C'
        assert check_call.call_args[0][0][2] == '/some/dufl/root'
Exemplo n.º 2
0
def test_git_run_raises_on_exception_failure():
    with patch_utils('check_call') as check_call:
        git = Git('/usr/bin/git', '~/.dufl')
        check_call.side_effect = CalledProcessError(1, 1)
        try:
            git.run('pull')
            assert False
        except GitError:
            assert True
Exemplo n.º 3
0
def test_git_run_raises_on_status_failure():
    with patch_utils('check_call') as check_call:
        git = Git('/usr/bin/git', '~/.dufl')
        check_call.return_value = 1
        try:
            git.run('pull')
            assert False
        except GitError:
            assert True
Exemplo n.º 4
0
def test_git_run_runs_expected_command():
    with patch_utils('check_call') as check_call:
        git = Git('/usr/bin/git', '~/.dufl')
        check_call.return_value = 0
        git.run('remote', 'add', 'origin', 'http://github.com/example/example.git')
        assert check_call.call_args[0][0][3:] == ['remote', 'add', 'origin', 'http://github.com/example/example.git']
Exemplo n.º 5
0
def test_working_branch_returns_checkedout_branch(git):
    git.run('branch', 'somebranch')
    git.run('checkout', 'somebranch')
    assert git.working_branch() == 'somebranch'
    git.run('checkout', 'master')
    assert git.working_branch() == 'master'
Exemplo n.º 6
0
def test_git_run_invokes_provided_git_binary():
    with patch_utils('check_call') as check_call:
        git = Git('/some/bin/git', '~/.dufl')
        check_call.return_value = 0
        git.run('pull')
        assert check_call.call_args[0][0][0] == '/some/bin/git'