Exemple #1
0
def test_on_head_only_empty(mock_repo):
    """
    GIVEN GitWrapperCherry initialized with a path and repo
    WHEN on_head_only is called with no changes
    THEN an empty dictionary is returned
    """
    cherry = GitWrapperCherry('./', mock_repo)
    lines = ''
    attrs = {'cherry.return_value': lines}
    mock_repo.git.configure_mock(**attrs)
    assert {} == cherry.on_head_only('upstream', 'HEAD')
Exemple #2
0
def test_on_head_only_no_new(mock_repo):
    """
    GIVEN GitWrapperCherry initialized with a path and repo
    WHEN on_head_only method is called with a only upstream equivalent changes
    THEN an empty dictionary is returned
    """
    cherry = GitWrapperCherry('./', mock_repo)
    lines = '- sha1 commit1\n- sha2 commit2\n- sha3 commit3'
    attrs = {'cherry.return_value': lines}
    mock_repo.git.configure_mock(**attrs)
    assert {} == cherry.on_head_only('upstream', 'HEAD')
Exemple #3
0
def test_on_head_only_all_new(mock_repo):
    """
    GIVEN GitWrapperCherry initialized with a path and repo
    WHEN on_head_only method is called with no upstream equivalent changes
    THEN a dictionary is returned containing two sha1's and commits
    """
    cherry = GitWrapperCherry('./', mock_repo)
    lines = '+ sha1 commit1\n+ sha2 commit2\n+ sha3 commit3'
    attrs = {'cherry.return_value': lines}
    mock_repo.git.configure_mock(**attrs)
    expected = {'sha1': 'commit1', 'sha2': 'commit2', 'sha3': 'commit3'}
    assert expected == cherry.on_head_only('upstream', 'HEAD')