Completed
Push — master ( 8a4bd9...eaa167 )
by Michael
01:20
created

test_determine_repository_url_should_clone()   B

Complexity

Conditions 2

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 2
c 3
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
def test_determine_repository_url_should_clone(
19
        mocker, template_url, user_config_data):
20
    """`clone()` should be called with correct args when `cookiecutter()` is
21
    called.
22
    """
23
24
    mock_clone = mocker.patch(
25
        'cookiecutter.repository.clone',
26
        return_value='tests/fake-repo-tmpl',
27
        autospec=True
28
    )
29
30
    project_dir = determine_repo_dir(
31
        template_url,
32
        abbreviations={},
33
        clone_to_dir=user_config_data['cookiecutters_dir'],
34
        checkout=None,
35
        no_input=True
36
    )
37
38
    mock_clone.assert_called_once_with(
39
        repo_url=template_url,
40
        checkout=None,
41
        clone_to_dir=user_config_data['cookiecutters_dir'],
42
        no_input=True
43
    )
44
45
    assert os.path.isdir(project_dir)
46