Skip to content

Commit 43ba80c

Browse files
committed
Format tests with psf/black
As recommended by @TG1999 Signed-off-by: Alexander Mazuruk <[email protected]>
1 parent 1829791 commit 43ba80c

File tree

3 files changed

+184
-45
lines changed

3 files changed

+184
-45
lines changed

tests/test_fetch.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -21,45 +21,45 @@
2121
from fetchcode import fetch
2222

2323

24-
@mock.patch('fetchcode.requests.get')
24+
@mock.patch("fetchcode.requests.get")
2525
def test_fetch_http_with_tempfile(mock_get):
2626
mock_get.return_value.headers = {
27-
'content-type': 'image/png',
28-
'content-length': '1000999',
27+
"content-type": "image/png",
28+
"content-length": "1000999",
2929
}
3030

31-
with mock.patch('fetchcode.open', mock.mock_open()) as mocked_file:
32-
url = 'https://raw.githubusercontent.com/TG1999/converge/master/assets/Group%2022.png'
31+
with mock.patch("fetchcode.open", mock.mock_open()) as mocked_file:
32+
url = "https://raw.githubusercontent.com/TG1999/converge/master/assets/Group%2022.png"
3333
response = fetch(url=url)
3434
assert response is not None
3535
assert 1000999 == response.size
3636
assert url == response.url
37-
assert 'image/png' == response.content_type
37+
assert "image/png" == response.content_type
3838

3939

40-
@mock.patch('fetchcode.FTP')
40+
@mock.patch("fetchcode.FTP")
4141
def test_fetch_with_wrong_url(mock_get):
4242
with pytest.raises(Exception) as e_info:
43-
url = 'ftp://speedtest/1KB.zip'
43+
url = "ftp://speedtest/1KB.zip"
4444
response = fetch(url=url)
45-
assert 'Not a valid URL' == e_info
45+
assert "Not a valid URL" == e_info
4646

4747

48-
@mock.patch('fetchcode.FTP', autospec=True)
48+
@mock.patch("fetchcode.FTP", autospec=True)
4949
def test_fetch_ftp_with_tempfile(mock_ftp_constructor):
5050
mock_ftp = mock_ftp_constructor.return_value
5151
mock_ftp_constructor.return_value.size.return_value = 1024
52-
with mock.patch('fetchcode.open', mock.mock_open()) as mocked_file:
53-
response = fetch('ftp://speedtest.tele2.net/1KB.zip')
52+
with mock.patch("fetchcode.open", mock.mock_open()) as mocked_file:
53+
response = fetch("ftp://speedtest.tele2.net/1KB.zip")
5454
assert 1024 == response.size
55-
mock_ftp_constructor.assert_called_with('speedtest.tele2.net')
55+
mock_ftp_constructor.assert_called_with("speedtest.tele2.net")
5656
assert mock_ftp.login.called == True
57-
mock_ftp.cwd.assert_called_with('/')
57+
mock_ftp.cwd.assert_called_with("/")
5858
assert mock_ftp.retrbinary.called
5959

6060

6161
def test_fetch_with_scheme_not_present():
6262
with pytest.raises(Exception) as e_info:
63-
url = 'abc://speedtest/1KB.zip'
63+
url = "abc://speedtest/1KB.zip"
6464
response = fetch(url=url)
65-
assert 'Not a supported/known scheme.' == e_info
65+
assert "Not a supported/known scheme." == e_info

tests/test_vcs.py

+134-23
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,142 @@
2525
def obtain(dest, url):
2626
pass
2727

28+
2829
@pytest.mark.parametrize(
2930
"url, vcs_type, domain",
3031
[
31-
pytest.param("git+http://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_http"),
32-
pytest.param("git://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git"),
33-
pytest.param("git+https://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_https"),
34-
pytest.param("git+ssh://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_ssh"),
35-
pytest.param("git+file://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_file"),
36-
pytest.param("git+git://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_git"),
37-
pytest.param("bzr+http://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr_http"),
38-
pytest.param("bzr+https://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr_https"),
39-
pytest.param("bzr://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr"),
40-
pytest.param("bzr+ssh://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr_ssh"),
41-
pytest.param("bzr+ftp://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr_ftp"),
42-
pytest.param("bzr+sftp://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr_sftp"),
43-
pytest.param("bzr+lp://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr_lp"),
44-
pytest.param("hg://bitbucket.com/jamesor/mongoose-versioner", "hg", "bitbucket.com", id="hg"),
45-
pytest.param("hg+file://bitbucket.com/jamesor/mongoose-versioner", "hg", "bitbucket.com", id="hg_file"),
46-
pytest.param("hg+http://bitbucket.com/jamesor/mongoose-versioner", "hg", "bitbucket.com", id="hg_http"),
47-
pytest.param("hg+https://bitbucket.com/jamesor/mongoose-versioner", "hg", "bitbucket.com", id="hg_https"),
48-
pytest.param("hg+ssh://bitbucket.com/jamesor/mongoose-versioner", "hg", "bitbucket.com", id="hg_ssh"),
49-
pytest.param("hg+static-http://bitbucket.com/jamesor/mongoose-versioner", "hg", "bitbucket.com", id="hg_static_http"),
50-
pytest.param("svn://bitbucket.com/jamesor/mongoose-versioner", "svn", "bitbucket.com", id="svn"),
51-
pytest.param("svn+http://bitbucket.com/jamesor/mongoose-versioner", "svn", "bitbucket.com", id="svn_http"),
52-
pytest.param("svn+https://bitbucket.com/jamesor/mongoose-versioner", "svn", "bitbucket.com", id="svn_https"),
53-
pytest.param("svn+svn://bitbucket.com/jamesor/mongoose-versioner", "svn", "bitbucket.com", id="svn_svn")
32+
pytest.param(
33+
"git+http://github.com/jamesor/mongoose-versioner",
34+
"git",
35+
"github.com",
36+
id="git_http",
37+
),
38+
pytest.param(
39+
"git://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git"
40+
),
41+
pytest.param(
42+
"git+https://github.com/jamesor/mongoose-versioner",
43+
"git",
44+
"github.com",
45+
id="git_https",
46+
),
47+
pytest.param(
48+
"git+ssh://github.com/jamesor/mongoose-versioner",
49+
"git",
50+
"github.com",
51+
id="git_ssh",
52+
),
53+
pytest.param(
54+
"git+file://github.com/jamesor/mongoose-versioner",
55+
"git",
56+
"github.com",
57+
id="git_file",
58+
),
59+
pytest.param(
60+
"git+git://github.com/jamesor/mongoose-versioner",
61+
"git",
62+
"github.com",
63+
id="git_git",
64+
),
65+
pytest.param(
66+
"bzr+http://gitlab.com/jamesor/mongoose-versioner",
67+
"bzr",
68+
"gitlab.com",
69+
id="bzr_http",
70+
),
71+
pytest.param(
72+
"bzr+https://gitlab.com/jamesor/mongoose-versioner",
73+
"bzr",
74+
"gitlab.com",
75+
id="bzr_https",
76+
),
77+
pytest.param(
78+
"bzr://gitlab.com/jamesor/mongoose-versioner", "bzr", "gitlab.com", id="bzr"
79+
),
80+
pytest.param(
81+
"bzr+ssh://gitlab.com/jamesor/mongoose-versioner",
82+
"bzr",
83+
"gitlab.com",
84+
id="bzr_ssh",
85+
),
86+
pytest.param(
87+
"bzr+ftp://gitlab.com/jamesor/mongoose-versioner",
88+
"bzr",
89+
"gitlab.com",
90+
id="bzr_ftp",
91+
),
92+
pytest.param(
93+
"bzr+sftp://gitlab.com/jamesor/mongoose-versioner",
94+
"bzr",
95+
"gitlab.com",
96+
id="bzr_sftp",
97+
),
98+
pytest.param(
99+
"bzr+lp://gitlab.com/jamesor/mongoose-versioner",
100+
"bzr",
101+
"gitlab.com",
102+
id="bzr_lp",
103+
),
104+
pytest.param(
105+
"hg://bitbucket.com/jamesor/mongoose-versioner",
106+
"hg",
107+
"bitbucket.com",
108+
id="hg",
109+
),
110+
pytest.param(
111+
"hg+file://bitbucket.com/jamesor/mongoose-versioner",
112+
"hg",
113+
"bitbucket.com",
114+
id="hg_file",
115+
),
116+
pytest.param(
117+
"hg+http://bitbucket.com/jamesor/mongoose-versioner",
118+
"hg",
119+
"bitbucket.com",
120+
id="hg_http",
121+
),
122+
pytest.param(
123+
"hg+https://bitbucket.com/jamesor/mongoose-versioner",
124+
"hg",
125+
"bitbucket.com",
126+
id="hg_https",
127+
),
128+
pytest.param(
129+
"hg+ssh://bitbucket.com/jamesor/mongoose-versioner",
130+
"hg",
131+
"bitbucket.com",
132+
id="hg_ssh",
133+
),
134+
pytest.param(
135+
"hg+static-http://bitbucket.com/jamesor/mongoose-versioner",
136+
"hg",
137+
"bitbucket.com",
138+
id="hg_static_http",
139+
),
140+
pytest.param(
141+
"svn://bitbucket.com/jamesor/mongoose-versioner",
142+
"svn",
143+
"bitbucket.com",
144+
id="svn",
145+
),
146+
pytest.param(
147+
"svn+http://bitbucket.com/jamesor/mongoose-versioner",
148+
"svn",
149+
"bitbucket.com",
150+
id="svn_http",
151+
),
152+
pytest.param(
153+
"svn+https://bitbucket.com/jamesor/mongoose-versioner",
154+
"svn",
155+
"bitbucket.com",
156+
id="svn_https",
157+
),
158+
pytest.param(
159+
"svn+svn://bitbucket.com/jamesor/mongoose-versioner",
160+
"svn",
161+
"bitbucket.com",
162+
id="svn_svn",
163+
),
54164
],
55165
)
56166
@mock.patch("fetchcode.vcs.vcs.get_backend_for_scheme")
@@ -60,6 +170,7 @@ def test_fetch_via_vcs_returns_response(mock_backend, url, vcs_type, domain):
60170
assert response.vcs_type == vcs_type
61171
assert response.domain == domain
62172

173+
63174
def test_fetch_with_invalid_scheme():
64175
invalid_urls = [
65176
"https://github.com/TG1999/fetchcode",

tests/test_vcs_git.py

+34-6
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,39 @@ def obtain(dest, url):
2828
@pytest.mark.parametrize(
2929
"url, vcs_type, domain",
3030
[
31-
pytest.param("git+http://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_http"),
32-
pytest.param("git://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git"),
33-
pytest.param("git+https://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_https"),
34-
pytest.param("git+ssh://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_ssh"),
35-
pytest.param("git+file://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_file"),
36-
pytest.param("git+git://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git_git")
31+
pytest.param(
32+
"git+http://github.com/jamesor/mongoose-versioner",
33+
"git",
34+
"github.com",
35+
id="git_http",
36+
),
37+
pytest.param(
38+
"git://github.com/jamesor/mongoose-versioner", "git", "github.com", id="git"
39+
),
40+
pytest.param(
41+
"git+https://github.com/jamesor/mongoose-versioner",
42+
"git",
43+
"github.com",
44+
id="git_https",
45+
),
46+
pytest.param(
47+
"git+ssh://github.com/jamesor/mongoose-versioner",
48+
"git",
49+
"github.com",
50+
id="git_ssh",
51+
),
52+
pytest.param(
53+
"git+file://github.com/jamesor/mongoose-versioner",
54+
"git",
55+
"github.com",
56+
id="git_file",
57+
),
58+
pytest.param(
59+
"git+git://github.com/jamesor/mongoose-versioner",
60+
"git",
61+
"github.com",
62+
id="git_git",
63+
),
3764
],
3865
)
3966
@mock.patch("fetchcode.vcs.git.vcs.get_backend")
@@ -43,6 +70,7 @@ def test_fetch_via_vcs_returns_response(mock_backend, url, vcs_type, domain):
4370
assert response.vcs_type == vcs_type
4471
assert response.domain == domain
4572

73+
4674
def test_fetch_with_git_invalid_scheme():
4775
invalid_urls = [
4876
"https://github.com/TG1999/fetchcode",

0 commit comments

Comments
 (0)