1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
import pytest |
3
|
|
|
|
4
|
|
|
from cookiecutter import exceptions, vcs |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
@pytest.mark.parametrize('repo_url, exp_repo_type, exp_repo_url', [ |
8
|
|
|
( |
9
|
|
|
'git+https://github.com/pytest-dev/cookiecutter-pytest-plugin.git', |
10
|
|
|
'git', |
11
|
|
|
'https://github.com/pytest-dev/cookiecutter-pytest-plugin.git' |
12
|
|
|
), ( |
13
|
|
|
'hg+https://bitbucket.org/foo/bar.hg', |
14
|
|
|
'hg', |
15
|
|
|
'https://bitbucket.org/foo/bar.hg' |
16
|
|
|
), ( |
17
|
|
|
'https://github.com/pytest-dev/cookiecutter-pytest-plugin.git', |
18
|
|
|
'git', |
19
|
|
|
'https://github.com/pytest-dev/cookiecutter-pytest-plugin.git' |
20
|
|
|
), ( |
21
|
|
|
'https://bitbucket.org/foo/bar.hg', |
22
|
|
|
'hg', |
23
|
|
|
'https://bitbucket.org/foo/bar.hg' |
24
|
|
|
), ( |
25
|
|
|
'https://github.com/audreyr/cookiecutter-pypackage.git', |
26
|
|
|
'git', |
27
|
|
|
'https://github.com/audreyr/cookiecutter-pypackage.git', |
28
|
|
|
), ( |
29
|
|
|
'https://github.com/audreyr/cookiecutter-pypackage', |
30
|
|
|
'git', |
31
|
|
|
'https://github.com/audreyr/cookiecutter-pypackage', |
32
|
|
|
), ( |
33
|
|
|
'[email protected]:cookiecutter-gitorious/cookiecutter-gitorious.git', |
34
|
|
|
'git', |
35
|
|
|
'[email protected]:cookiecutter-gitorious/cookiecutter-gitorious.git', |
36
|
|
|
), ( |
37
|
|
|
'https://[email protected]/audreyr/cookiecutter-bitbucket', |
38
|
|
|
'hg', |
39
|
|
|
'https://[email protected]/audreyr/cookiecutter-bitbucket', |
40
|
|
|
) |
41
|
|
|
]) |
42
|
|
|
def test_identify_known_repo(repo_url, exp_repo_type, exp_repo_url): |
43
|
|
|
assert vcs.identify_repo(repo_url) == (exp_repo_type, exp_repo_url) |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
@pytest.fixture(params=[ |
47
|
|
|
'foo+git', # uses explicit identifier with 'git' in the wrong place |
48
|
|
|
'foo+hg', # uses explicit identifier with 'hg' in the wrong place |
49
|
|
|
'foo+bar', # uses explicit identifier with neither 'git' nor 'hg' |
50
|
|
|
'foobar', # no identifier but neither 'git' nor 'bitbucket' in url |
51
|
|
|
'http://norepotypespecified.com' |
52
|
|
|
]) |
53
|
|
|
def unknown_repo_type_url(request): |
54
|
|
|
return request.param |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
def test_identify_raise_on_unknown_repo(unknown_repo_type_url): |
58
|
|
|
with pytest.raises(exceptions.UnknownRepoType): |
59
|
|
|
vcs.identify_repo(unknown_repo_type_url) |
60
|
|
|
|