def test_stash_error(): """ Run 'git up' with an error while stashing """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_bundler(): """ Run bundler integration """ shell = True if platform.system() == 'Windows' else False if os.environ.get('TRAVIS', False): raise SkipTest('Skip this test on Travis CI :(') # Helper methods def is_installed(prog): dev_null = open(os.devnull, 'wb') return_value = subprocess.call([prog, '--version'], shell=shell, stdout=dev_null, stderr=dev_null) return return_value == 0 def get_output(cmd): return subprocess.check_output(cmd, shell=shell) # Check for ruby and bundler if not (is_installed('ruby') and is_installed('gem') and 'bundler' in get_output(['gem', 'list'])): # Ruby not installed, skip test raise SkipTest('Ruby not installed, skipped Bundler integration test') os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_unstash_error(): """ Run 'git up' with an unclean unstash """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_fetch_fail(): """ Run 'git up' with a non-existent remote """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_bundler(): """ Run bundler integration """ shell = True if platform.system() == 'Windows' else False if os.environ.get('TRAVIS', False): raise SkipTest('Skip this test on Travis CI :(') # Helper methods def is_installed(prog): dev_null = open(os.devnull, 'wb') try: return_value = subprocess.call([prog, '--version'], shell=shell, stdout=dev_null, stderr=dev_null) return return_value == 0 except OSError: return False def get_output(cmd): return str(subprocess.check_output(cmd, shell=shell)) # Check for ruby and bundler if not (is_installed('ruby') and is_installed('gem') and 'bundler' in get_output(['gem', 'list'])): # Ruby not installed, skip test raise SkipTest('Ruby not installed, skipped Bundler integration test') os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_detached(): """ Run 'git up' with detached head """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_rebase_error(): """ Run 'git up' with a failing rebase """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_submodules(): """ Run 'git up' with submodules """ repo = Repo(repo_path) repo_head = repo.head.commit.hexsha submod_head = repo.submodules[0].hexsha os.chdir(join(repo_path, 'sub')) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) # PyGitUp uses the submodule instead of the toplevel git repo assert_equal(submod_head, gitup.git.repo.head.commit.hexsha) gitup.run() repo = Repo(repo_path) assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding') # Repo itself is unchanged: assert_equal(repo.head.commit.hexsha, repo_head) # Submodule is changed: assert_not_equal(gitup.git.repo.head.commit.hexsha, submod_head)
def test_checkout_error(): """ Run 'git up' with checkout errors """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_submodules(): """ Run 'git up' with submodules """ repo = Repo(repo_path) repo_head = repo.head.commit.hexsha submod_head = repo.submodules[0].hexsha os.chdir(join(repo_path, 'sub')) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) # PyGitUp uses the submodule instead of the toplevel git repo assert submod_head == gitup.git.repo.head.commit.hexsha gitup.run() repo = Repo(repo_path) assert len(gitup.states) == 1 assert gitup.states[0] == 'fast-forwarding' # Repo itself is unchanged: assert repo.head.commit.hexsha, repo_head # Submodule is changed: assert gitup.git.repo.head.commit.hexsha != submod_head
def test_fast_forwarded(): """ Fail correctly when a rebase would overwrite untracked files """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()
def test_out_of_tree(): """ Run 'git up' with an out-of-tree source """ os.chdir(work_tree) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(gitup.states, ['fast-forwarding'])
def test_out_of_tree(): """ Run 'git up' with an out-of-tree source """ os.chdir(work_tree) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert gitup.states == ['fast-forwarding']
def test_detached(): """ Run 'git up' with detached head """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) with pytest.raises(GitError): gitup.run()
def test_ahead_of_upstream(): """ Run 'git up' with result: ahead of upstream """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'ahead')
def test_fast_forwarded(): """ Run 'git up' with result: fast-forwarding """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding')
def test_remote_branch_deleted(): """ Run 'git up' with remotely deleted branch """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 2) assert_equal(gitup.states[1], 'remote branch doesn\'t exist')
def test_rebasing(): """ Run 'git up' with result: rebasing """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert len(gitup.states) == 1 assert gitup.states[0] == 'rebasing'
def test_issue_55(): """ Regression test for #55 """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding')
def test_diverged(): """ Run 'git up' with result: diverged """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'diverged')
def test_up_to_date(): """ Run 'git up' with result: up to date """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'up to date')
def test_ahead_of_upstream(): """ Run 'git up' with result: ahead of upstream """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert len(gitup.states) == 1 assert gitup.states[0] == 'ahead'
def test_log_hook(): """ Run 'git up' with log-hook""" os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding')
def test_fast_forwarded(): """ Run 'git up' with result: fast-forwarding """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert len(gitup.states) == 1 assert gitup.states[0] == 'fast-forwarding'
def test_rebase_arguments(): """ Run 'git up' with rebasing.arguments """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'rebasing')
def test_tracking(): """ Run 'git up' with a local tracking branch """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding')
def test_fast_forwarded(): """ Run 'git up' with multiple remotes """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 2) assert_equal(gitup.states[0], 'fast-forwarding') assert_equal(gitup.states[1], 'fast-forwarding')
def test_returning_to_branch(): """ Run 'git up': return to branch """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding') assert_equal(gitup.repo.head.ref.name, new_branch_name)
def test_rebasing(): """ Run 'git up' with pushing to origin """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.settings['push.auto'] = True gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'rebasing') assert_equal(gitup.pushed, True)
def test_rebase_arguments(): """ Run 'git up' with rebasing.arguments """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) with pytest.raises(RebaseError): gitup.run() assert len(gitup.states) == 1 assert gitup.states[0] == 'rebasing'
def test_rebasing(): """ Run 'git up' with pushing to origin """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.settings['push.auto'] = True gitup.run() assert len(gitup.states) == 1 assert gitup.states[0] == 'rebasing' assert gitup.pushed
def test_run_in_subdir(): """ Run 'git up' in a subdir of the repo """ subdir = join(repo_path, 'dir') os.mkdir(subdir) os.chdir(subdir) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'fast-forwarding')
def test_separate_worktree(): """ Run 'git up' with separate work tree """ if Git().version_info[:3] < (2, 5, 1): raise SkipTest('Skip this test on Travis CI :(') os.chdir(worktree_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert len(gitup.states) == 1 assert gitup.states[0] == 'fast-forwarding'
def test_separate_worktree(): """ Run 'git up' with separate work tree """ if Git().version_info[:3] < (2, 5, 1): raise SkipTest("Skip this test on Travis CI :(") os.chdir(worktree_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], "fast-forwarding")
def test_fetchall(): """ Run 'git up' with fetch.all """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) with capture() as [stdout, _]: gitup.run() stdout = stdout.getvalue() assert_true('origin' in stdout) assert_true(test_name in stdout)
def test_no_remotes(): """ Run 'git up' w/o remotes """ os.chdir(master_path) from PyGitUp.gitup import GitUp with pytest.raises(GitError): GitUp(testing=True)
def test_submodules_dirty(): """ Run 'git up' with submodules in a dirty repo """ repo = Repo(repo_path) repo_head = repo.head.commit.hexsha submod_head = repo.submodules[0].hexsha # Change file in submodule write_file('sub/file', 'submodule changed') from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) # PyGitUp uses the main repo assert_equal(repo_head, gitup.git.repo.head.commit.hexsha) gitup.run() assert_equal(len(gitup.states), 1) assert_equal(gitup.states[0], 'rebasing')
def test_no_fetch(): """ Run 'git up' with '--no-fetch' argument """ os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.should_fetch = False with capture() as [stdout, _]: gitup.run() stdout = stdout.getvalue() assert_false('Fetching' in stdout) assert_true('rebasing' in stdout) assert_true('up to date' in stdout) assert_true(test_name in stdout) assert_true(new_branch_name in stdout)
def test_faster_forwarded(): """ Run 'git up' with result: (fast) fast-forwarding """ os.chdir(repo_path) assert_not_equal(master.branches[test_name].commit, repo.branches[test_name].commit) assert_not_equal(master.branches[test_name].commit, repo.branches[test_name + '.2'].commit) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run() assert_equal(len(gitup.states), 2) assert_equal(gitup.states[0], 'fast-forwarding') assert_equal(gitup.states[1], 'fast-forwarding') assert_equal(master.branches[test_name].commit, repo.branches[test_name].commit) assert_equal(master.branches[test_name].commit, repo.branches[test_name + '.2'].commit)
def test_bundler(): """ Run bundler integration """ if os.environ.get('TRAVIS', False): raise SkipTest('Skip this test on Travis CI :(') def is_installed(prog): dev_null = open(os.devnull, 'wb') return_value = subprocess.call([prog, '--version'], shell=True, stdout=dev_null, stderr=dev_null) return return_value == 0 if not (is_installed('ruby') and is_installed('gem')): # Ruby not installed, skip test raise SkipTest('Ruby not installed, skipped Bundler integration test') os.chdir(repo_path) from PyGitUp.gitup import GitUp gitup = GitUp(testing=True) gitup.run()