예제 #1
0
def test_prompt_should_not_ask_if_no_input_and_rm_repo_dir(mocker, tmpdir):
    """In `prompt_and_delete_repo()`, if `no_input` is True, the call to
    `vcs.read_user_yes_no()` should be suppressed.
    """
    mock_read_user = mocker.patch('cookiecutter.vcs.read_user_yes_no',
                                  return_value=True,
                                  autospec=True)
    repo_dir = tmpdir.mkdir('repo')

    vcs.prompt_and_delete_repo(str(repo_dir), no_input=True)

    assert not mock_read_user.called
    assert not repo_dir.exists()
예제 #2
0
def test_prompt_should_ask_and_rm_repo_dir(mocker, tmpdir):
    """In `prompt_and_delete_repo()`, if the user agrees to delete/reclone the
    repo, the repo should be deleted.
    """
    mock_read_user = mocker.patch('cookiecutter.vcs.read_user_yes_no',
                                  return_value=True,
                                  autospec=True)
    repo_dir = tmpdir.mkdir('repo')

    vcs.prompt_and_delete_repo(str(repo_dir))

    assert mock_read_user.called
    assert not repo_dir.exists()
예제 #3
0
def test_prompt_should_ask_and_keep_repo_dir(mocker, tmpdir):
    """In `prompt_and_delete_repo()`, if the user wants to keep their old
    cloned template repo, it should not be deleted.
    """
    mock_read_user = mocker.patch('cookiecutter.vcs.read_user_yes_no',
                                  return_value=False,
                                  autospec=True)
    repo_dir = tmpdir.mkdir('repo')

    with pytest.raises(SystemExit):
        vcs.prompt_and_delete_repo(str(repo_dir))

    assert mock_read_user.called
    assert repo_dir.exists()
예제 #4
0
def test_prompt_should_not_ask_if_no_input_and_rm_repo_dir(mocker, tmpdir):
    """In `prompt_and_delete_repo()`, if `no_input` is True, the call to
    `vcs.read_user_yes_no()` should be suppressed.
    """
    mock_read_user = mocker.patch(
        'cookiecutter.vcs.read_user_yes_no',
        return_value=True,
        autospec=True
    )
    repo_dir = tmpdir.mkdir('repo')

    vcs.prompt_and_delete_repo(str(repo_dir), no_input=True)

    assert not mock_read_user.called
    assert not repo_dir.exists()
예제 #5
0
def test_prompt_should_ask_and_rm_repo_dir(mocker, tmpdir):
    """In `prompt_and_delete_repo()`, if the user agrees to delete/reclone the
    repo, the repo should be deleted.
    """
    mock_read_user = mocker.patch(
        'cookiecutter.vcs.read_user_yes_no',
        return_value=True,
        autospec=True
    )
    repo_dir = tmpdir.mkdir('repo')

    vcs.prompt_and_delete_repo(str(repo_dir))

    assert mock_read_user.called
    assert not repo_dir.exists()
예제 #6
0
def test_prompt_should_ask_and_keep_repo_dir(mocker, tmpdir):
    """In `prompt_and_delete_repo()`, if the user wants to keep their old
    cloned template repo, it should not be deleted.
    """
    mock_read_user = mocker.patch(
        'cookiecutter.vcs.read_user_yes_no',
        return_value=False,
        autospec=True
    )
    repo_dir = tmpdir.mkdir('repo')

    with pytest.raises(SystemExit):
        vcs.prompt_and_delete_repo(str(repo_dir))

    assert mock_read_user.called
    assert repo_dir.exists()