-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
test_vcs.py
124 lines (114 loc) · 3.75 KB
/
test_vcs.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from PyDigger import fetch
import os
import yaml
def test_vcs(tmpdir):
print(tmpdir)
config_file = os.environ['PYDIGGER_CONFIG'] = os.path.join(
tmpdir, 'config.yml')
print(os.environ['PYDIGGER_CONFIG'])
config = {'github-token': 'fake'}
with open(config_file, 'w') as outfile:
yaml.dump(config, outfile, default_flow_style=False)
# github plain url in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://github.com/user/project'
package.entry['version'] = '1.0'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://github.com/user/project',
'version': '1.0',
'github': True,
'gitlab': False,
'bitbucket': False,
'codeberg': False,
'github_user': 'user',
'github_project': 'project'
}
# github plain url with trailing slash in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://github.com/user/project/'
package.entry['version'] = '1.0'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://github.com/user/project/',
'version': '1.0',
'github': True,
'gitlab': False,
'bitbucket': False,
'codeberg': False,
'github_user': 'user',
'github_project': 'project'
}
# gitlab plain url + version is a string in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://gitlab.com/user/project'
package.entry['version'] = 'abc'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://gitlab.com/user/project',
'version': 'abc',
'github': False,
'gitlab': True,
'bitbucket': False,
'codeberg': False,
'gitlab_user': 'user',
'gitlab_project': 'project'
}
# non-vcs URL in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://pypi.org/user/project'
package.entry['version'] = 'abc'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://pypi.org/user/project',
'version': 'abc',
'github': False,
'gitlab': False,
'bitbucket': False,
'codeberg': False,
}
# github url with extra /tags in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://github.com/user/project/tags'
package.entry['version'] = '1.0'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://github.com/user/project/tags',
'version': '1.0',
'github': True,
'gitlab': False,
'bitbucket': False,
'codeberg': False,
'github_user': 'user',
'github_project': 'project'
}
# github url with extra .git in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://github.com/user/project.git'
package.entry['version'] = '1.0'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://github.com/user/project.git',
'version': '1.0',
'github': True,
'gitlab': False,
'bitbucket': False,
'codeberg': False,
'github_user': 'user',
'github_project': 'project'
}
# codeberg plain url in home_page
package = fetch.PyPackage("foo")
package.entry['home_page'] = 'https://codeberg.org/user/project'
package.entry['version'] = '1.0'
package.extract_vcs()
assert package.entry == {
'home_page': 'https://codeberg.org/user/project',
'version': '1.0',
'github': False,
'gitlab': False,
'bitbucket': False,
'codeberg': True,
'codeberg_user': 'user',
'codeberg_project': 'project'
}