forked from cookiecutter/cookiecutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_is_repo_url.py
75 lines (58 loc) · 2.18 KB
/
test_is_repo_url.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"""Tests for all supported cookiecutter template repository locations."""
import pytest
from cookiecutter.config import BUILTIN_ABBREVIATIONS
from cookiecutter.repository import expand_abbreviations, is_repo_url, is_zip_file
@pytest.fixture(
params=[
'/path/to/zipfile.zip',
'https://example.com/path/to/zipfile.zip',
'http://example.com/path/to/zipfile.zip',
]
)
def zipfile(request):
"""Fixture. Represent possible paths to zip file."""
return request.param
def test_is_zip_file(zipfile):
"""Verify is_repo_url works."""
assert is_zip_file(zipfile) is True
@pytest.fixture(
params=[
'gitolite@server:team/repo',
'git@github.com:audreyfeldroy/cookiecutter.git',
'https://github.com/cookiecutter/cookiecutter.git',
'git+https://private.com/gitrepo',
'hg+https://private.com/mercurialrepo',
'https://bitbucket.org/pokoli/cookiecutter.hg',
'file://server/path/to/repo.git',
]
)
def remote_repo_url(request):
"""Fixture. Represent possible URI to different repositories types."""
return request.param
def test_is_repo_url_for_remote_urls(remote_repo_url):
"""Verify is_repo_url works."""
assert is_repo_url(remote_repo_url) is True
@pytest.fixture(
params=[
'/audreyr/cookiecutter.git',
'/home/audreyr/cookiecutter',
(
'c:\\users\\foo\\appdata\\local\\temp\\1\\pytest-0\\'
'test_default_output_dir0\\template'
),
]
)
def local_repo_url(request):
"""Fixture. Represent possible paths to local resources."""
return request.param
def test_is_repo_url_for_local_urls(local_repo_url):
"""Verify is_repo_url works."""
assert is_repo_url(local_repo_url) is False
def test_expand_abbreviations():
"""Validate `repository.expand_abbreviations` correctly translate url."""
template = 'gh:audreyfeldroy/cookiecutter-pypackage'
# This is not a valid repo url just yet!
# First `repository.expand_abbreviations` needs to translate it
assert is_repo_url(template) is False
expanded_template = expand_abbreviations(template, BUILTIN_ABBREVIATIONS)
assert is_repo_url(expanded_template) is True