1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
|
3
|
|
|
import pytest |
4
|
|
|
|
5
|
|
|
from cookiecutter.main import is_repo_url, expand_abbreviations |
6
|
|
|
|
7
|
|
|
|
8
|
|
|
@pytest.fixture(params=[ |
9
|
|
|
'gitolite@server:team/repo', |
10
|
|
|
'[email protected]:audreyr/cookiecutter.git', |
11
|
|
|
'https://github.com/audreyr/cookiecutter.git', |
12
|
|
|
'git+https://private.com/gitrepo', |
13
|
|
|
'hg+https://private.com/mercurialrepo', |
14
|
|
|
'https://bitbucket.org/pokoli/cookiecutter.hg', |
15
|
|
|
]) |
16
|
|
|
def remote_repo_url(request): |
17
|
|
|
return request.param |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
def test_is_repo_url_for_remote_urls(remote_repo_url): |
21
|
|
|
"""Verify is_repo_url works.""" |
22
|
|
|
assert is_repo_url(remote_repo_url) is True |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
@pytest.fixture(params=[ |
26
|
|
|
'/audreyr/cookiecutter.git', |
27
|
|
|
'/home/audreyr/cookiecutter', |
28
|
|
|
( |
29
|
|
|
'c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-0\\' |
30
|
|
|
'test_default_output_dir0\\template' |
31
|
|
|
), |
32
|
|
|
]) |
33
|
|
|
def local_repo_url(request): |
34
|
|
|
return request.param |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
def test_is_repo_url_for_local_urls(local_repo_url): |
38
|
|
|
"""Verify is_repo_url works.""" |
39
|
|
|
assert is_repo_url(local_repo_url) is False |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
def test_expand_abbreviations(): |
43
|
|
|
template = 'gh:audreyr/cookiecutter-pypackage' |
44
|
|
|
|
45
|
|
|
# This is not a valid repo url just yet! |
46
|
|
|
# First `main.expand_abbreviations` needs to translate it |
47
|
|
|
assert is_repo_url(template) is False |
48
|
|
|
|
49
|
|
|
expanded_template = expand_abbreviations(template, {}) |
50
|
|
|
assert is_repo_url(expanded_template) is True |
51
|
|
|
|