-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathtest_exporters.py
More file actions
64 lines (57 loc) · 2.16 KB
/
Copy pathtest_exporters.py
File metadata and controls
64 lines (57 loc) · 2.16 KB
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
import pytest
from committime.collector_base import CommitMetric
# Unit tests for the CommitMetric
@pytest.mark.parametrize("appname", [("pytest")])
def test_commitmetric_initial(appname):
metric = CommitMetric(appname)
assert metric.repo_url is None
assert metric.name == appname
assert metric.repo_protocol is None
assert metric.git_fqdn is None
assert metric.repo_group is None
assert metric.repo_project is None
@pytest.mark.parametrize(
"url,repo_protocol,fqdn,project_name",
[
("https://dogs.git.foo/dogs/repo.git", "https", "dogs.git.foo", "repo"),
("http://dogs.git.foo/dogs/repo.git", "http", "dogs.git.foo", "repo"),
("http://noabank.git.foo/chase/git.git", "http", "noabank.git.foo", "git"),
("ssh://git.moos.foo/maverick/tootsie.git", "ssh", "git.moos.foo", "tootsie"),
("git@github.com:konveyor/pelorus.git", "ssh", "github.com", "pelorus"),
(
"https://gitlab.com/firstgroup/secondgroup/myrepo.git",
"https",
"gitlab.com",
"myrepo",
),
],
)
def test_commitmetric_repos(url, repo_protocol, fqdn, project_name):
test_name = "pytest"
metric = CommitMetric(test_name)
metric.name == test_name
assert metric.repo_url is None
assert metric.repo_protocol is None
assert metric.git_fqdn is None
assert metric.repo_group is None
assert metric.repo_project is None
metric.repo_url = url
assert metric.repo_url is not None
assert metric.repo_url == url
assert metric.repo_protocol == repo_protocol
assert metric.git_fqdn is not None
assert metric.repo_group is not None
assert metric.repo_project is not None
assert metric.git_fqdn == fqdn
# assert metric.git_server == str(protocol + '://' + fqdn)
assert metric.repo_project == project_name
@pytest.mark.parametrize(
"malformed_url",
["kmoos://myprotocol/buffy/noext/noext", "notvalid://breakme/snoopy/gtist.git"],
)
def test_malformed_git_url(malformed_url):
test_name = "pytest"
metric = CommitMetric(test_name)
metric.name = test_name
with pytest.raises(ValueError):
metric.repo_url = malformed_url