Completed
Push — identify-cookiecutter-template ( 7a3bdf...be2324 )
by Michael
01:15
created

test_determine_repository_url_should_clone()   B

Complexity

Conditions 2

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 28
rs 8.8571
1
# -*- coding: utf-8 -*-
2
import os
3
4
import pytest
5
6
from cookiecutter.repository import determine_repo_dir
7
8
9
@pytest.fixture
10
def template_url():
11
    """URL to example Cookiecutter template on GitHub.
12
13
    Note: when used, git clone is mocked.
14
    """
15
    return 'https://github.com/pytest-dev/cookiecutter-pytest-plugin.git'
16
17
18
@pytest.fixture
19
def output_dir(tmpdir):
20
    """Given a temporary dir, create an `output` subdirectory inside it and
21
    return its path (not a str but a py.path instance).
22
    """
23
    return tmpdir.mkdir('output')
24
25
26
def test_determine_repository_url_should_clone(
27
        mocker, template_url, output_dir, user_config_file, user_config_data):
28
    """`clone()` should be called with correct args when `cookiecutter()` is
29
    called.
30
    """
31
32
    mock_clone = mocker.patch(
33
        'cookiecutter.repository.clone',
34
        return_value='tests/fake-repo-tmpl',
35
        autospec=True
36
    )
37
38
    project_dir = determine_repo_dir(
39
        template_url,
40
        abbreviations={},
41
        cookiecutters_dir=user_config_data['cookiecutters_dir'],
42
        checkout=None,
43
        no_input=True
44
    )
45
46
    mock_clone.assert_called_once_with(
47
        repo_url=template_url,
48
        checkout=None,
49
        clone_to_dir=user_config_data['cookiecutters_dir'],
50
        no_input=True
51
    )
52
53
    assert os.path.isdir(project_dir)
54