Exemple #1
0
def test_clone_repo(mock_git):
    mock_repo = mock.Mock()
    mock_git.Repo = mock_repo
    git.is_git_repo = mock.MagicMock(return_value=False)

    git.clone_or_pull_project(
        GitAction(Node(name="dummy_url", url="dummy_url"), "dummy_dir"))

    mock_git.Repo.clone_from.assert_called_once_with("dummy_url", "dummy_dir")
Exemple #2
0
def test_pull_repo(mock_git):
    mock_repo = mock.Mock()
    mock_git.Repo = mock_repo
    repo_instance = mock_git.Repo.return_value
    git.is_git_repo = mock.MagicMock(return_value=True)

    git.clone_or_pull_project(GitAction(Node(name="test"), "dummy_dir"))
    mock_git.Repo.assert_called_once_with("dummy_dir")
    repo_instance.remotes.origin.pull.assert_called_once()
Exemple #3
0
def test_clone_repo_recursive(mock_git):
    mock_repo = mock.Mock()
    mock_git.Repo = mock_repo
    git.is_git_repo = mock.MagicMock(return_value=False)

    git.clone_or_pull_project(
        GitAction(Node(name="dummy_url", url="dummy_url"),
                  "dummy_dir",
                  recursive=True))

    mock_git.Repo.clone_from.assert_called_once_with(
        "dummy_url", "dummy_dir", multi_options=['--recursive'])
Exemple #4
0
def test_clone_repo_interrupt(mock_git):
    mock_repo = mock.Mock()
    mock_git.Repo = mock_repo
    git.is_git_repo = mock.MagicMock(return_value=False)
    mock_git.Repo.clone_from.side_effect = KeyboardInterrupt(
        'clone test keyboard interrupt')

    with pytest.raises(SystemExit):
        git.clone_or_pull_project(
            GitAction(Node(name="dummy_url", url="dummy_url"), "dummy_dir"))

    mock_git.Repo.clone_from.assert_called_once_with("dummy_url", "dummy_dir")
Exemple #5
0
def test_pull_repo_exception(mock_git):
    mock_repo = mock.Mock()
    mock_git.Repo = mock_repo
    git.is_git_repo = mock.MagicMock(return_value=True)

    repo_instance = mock_git.Repo.return_value
    repo_instance.remotes.origin.pull.side_effect = Exception(
        'pull test exception')

    git.clone_or_pull_project(
        GitAction(Node(name="dummy_url", url="dummy_url"), "dummy_dir"))

    mock_git.Repo.assert_called_once_with("dummy_dir")
    repo_instance.remotes.origin.pull.assert_called_once()
Exemple #6
0
def test_pull_repo_interrupt(mock_git):
    mock_repo = mock.Mock()
    mock_git.Repo = mock_repo
    git.is_git_repo = mock.MagicMock(return_value=True)

    repo_instance = mock_git.Repo.return_value
    repo_instance.remotes.origin.pull.side_effect = KeyboardInterrupt(
        'pull test keyboard interrupt')

    with pytest.raises(SystemExit):
        git.clone_or_pull_project(
            GitAction(Node(name="dummy_url", url="dummy_url"), "dummy_dir"))

    mock_git.Repo.assert_called_once_with("dummy_dir")
    repo_instance.remotes.origin.pull.assert_called_once()