1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
from mock import patch
from paver import git
import os
@patch('paver.git.sh')
def test_simple_clone(sh):
git.clone("git://foo/foo.git", "bar")
assert sh.called
assert sh.call_args[0][0] == "git clone git://foo/foo.git bar"
@patch('paver.git.sh')
def test_simple_pull(sh):
git.pull("repo_path", "origin_remote", "master_branch")
assert sh.called
assert sh.call_args[0][0] == "cd repo_path; git pull origin_remote master_branch"
@patch('paver.git.sh')
def test_simple_branch_checkout(sh):
git.branch_checkout("my_branch", path="repo_path")
assert sh.called
assert sh.call_args[0][0] == "cd repo_path; git checkout my_branch"
@patch('paver.git.sh')
def test_branch_chekout_cwd(sh):
"""it should get the CWD and assume that is the repo"""
git.branch_checkout("my_branch")
assert sh.called
assert sh.call_args[0][0] == "cd %(current_path)s; git checkout my_branch" % dict(
current_path=os.getcwd()
)
@patch('paver.git.sh')
def test_branch_list_correctly_parses_git_output(sh):
output = git.branch_list(path="repo_path", __override__="""
* git_support
master
virtualenv_in_folder
""")
assert output == ("git_support", ["git_support", "master", "virtualenv_in_folder"])
@patch('paver.git.sh')
def test_branch_list_correctly_parses_remote_branch_output(sh):
output = git.branch_list(path="repo_path",
remote_branches_only = True,
__override__="""
github/gh-pages
github/git_support
github/master""")
assert output == ('',
["github/gh-pages", "github/git_support", "github/master"])
@patch('paver.git.sh')
def test_branch_track_remote(sh):
git.branch_track_remote("origin/alpha_two", path="repo_path")
assert sh.called
assert sh.call_args[0][0] == "cd %(current_path)s; git checkout -b alpha_two --track origin/alpha_two" % dict(
current_path="repo_path"
)
|