コード例 #1
0
ファイル: test_stash_error.py プロジェクト: winstonwp/PyGitUp
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()
コード例 #2
0
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()
コード例 #3
0
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()
コード例 #4
0
ファイル: test_fetch_fail.py プロジェクト: winstonwp/PyGitUp
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()
コード例 #5
0
ファイル: test_bundler.py プロジェクト: Javex/PyGitUp
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()
コード例 #6
0
ファイル: test_detached.py プロジェクト: winstonwp/PyGitUp
def test_detached():
    """ Run 'git up' with detached head """
    os.chdir(repo_path)

    from PyGitUp.gitup import GitUp
    gitup = GitUp(testing=True)
    gitup.run()
コード例 #7
0
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()
コード例 #8
0
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)
コード例 #9
0
ファイル: test_checkout_error.py プロジェクト: talwai/PyGitUp
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()
コード例 #10
0
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
コード例 #11
0
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()
コード例 #12
0
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()
コード例 #13
0
ファイル: test_out_of_tree.py プロジェクト: dragon788/PyGitUp
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'])
コード例 #14
0
ファイル: test_out_of_tree.py プロジェクト: x1g1/PyGitUp
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']
コード例 #15
0
ファイル: test_detached.py プロジェクト: x1g1/PyGitUp
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()
コード例 #16
0
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')
コード例 #17
0
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')
コード例 #18
0
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')
コード例 #19
0
ファイル: test_rebasing.py プロジェクト: x1g1/PyGitUp
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'
コード例 #20
0
ファイル: test_issue_55.py プロジェクト: winstonwp/PyGitUp
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')
コード例 #21
0
ファイル: test_diverged.py プロジェクト: winstonwp/PyGitUp
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')
コード例 #22
0
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')
コード例 #23
0
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'
コード例 #24
0
ファイル: test_log_hook.py プロジェクト: winstonwp/PyGitUp
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')
コード例 #25
0
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'
コード例 #26
0
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')
コード例 #27
0
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')
コード例 #28
0
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')
コード例 #29
0
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)
コード例 #30
0
ファイル: test_push.py プロジェクト: msiemens/PyGitUp
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)
コード例 #31
0
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'
コード例 #32
0
ファイル: test_push.py プロジェクト: x1g1/PyGitUp
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
コード例 #33
0
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')
コード例 #34
0
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'
コード例 #35
0
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")
コード例 #36
0
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)
コード例 #37
0
ファイル: test_no_remotes.py プロジェクト: x1g1/PyGitUp
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)
コード例 #38
0
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')
コード例 #39
0
ファイル: test_nofetch.py プロジェクト: msiemens/PyGitUp
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)
コード例 #40
0
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)
コード例 #41
0
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()