Skip to content

Commit 3af1236

Browse files
committed
refactor(parse): {vcs}_location -> {vcs}_url
1 parent 7730131 commit 3af1236

File tree

3 files changed

+91
-107
lines changed

3 files changed

+91
-107
lines changed

tests/parse/test_git.py

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
class GitURLFixture(typing.NamedTuple):
1111
url: str
1212
is_valid: bool
13-
git_location: GitURL
13+
git_url: GitURL
1414

1515

1616
TEST_FIXTURES: list[GitURLFixture] = [
1717
GitURLFixture(
1818
url="https://github.com/vcs-python/libvcs.git",
1919
is_valid=True,
20-
git_location=GitURL(
20+
git_url=GitURL(
2121
url="https://github.com/vcs-python/libvcs.git",
2222
scheme="https",
2323
hostname="github.com",
@@ -27,7 +27,7 @@ class GitURLFixture(typing.NamedTuple):
2727
GitURLFixture(
2828
url="https://github.com/vcs-python/libvcs",
2929
is_valid=True,
30-
git_location=GitURL(
30+
git_url=GitURL(
3131
url="https://github.com/vcs-python/libvcs",
3232
scheme="https",
3333
hostname="github.com",
@@ -37,7 +37,7 @@ class GitURLFixture(typing.NamedTuple):
3737
GitURLFixture(
3838
url="https://github.com:7999/vcs-python/libvcs",
3939
is_valid=True,
40-
git_location=GitURL(
40+
git_url=GitURL(
4141
url="https://github.com:7999/vcs-python/libvcs",
4242
scheme="https",
4343
hostname="github.com",
@@ -52,7 +52,7 @@ class GitURLFixture(typing.NamedTuple):
5252
GitURLFixture(
5353
url="git@github.com:liuxinyu95/AlgoXY.git",
5454
is_valid=True,
55-
git_location=GitURL(
55+
git_url=GitURL(
5656
url="git@github.com:liuxinyu95/AlgoXY.git",
5757
scheme=None,
5858
hostname="github.com",
@@ -62,7 +62,7 @@ class GitURLFixture(typing.NamedTuple):
6262
GitURLFixture(
6363
url="git@github.com:vcs-python/libvcs.git",
6464
is_valid=True,
65-
git_location=GitURL(
65+
git_url=GitURL(
6666
url="git@github.com:vcs-python/libvcs.git",
6767
scheme="https",
6868
hostname="github.com",
@@ -73,20 +73,20 @@ class GitURLFixture(typing.NamedTuple):
7373

7474

7575
@pytest.mark.parametrize(
76-
"url,is_valid,git_location",
76+
"url,is_valid,git_url",
7777
TEST_FIXTURES,
7878
)
79-
def test_git_location(
79+
def test_git_url(
8080
url: str,
8181
is_valid: bool,
82-
git_location: GitURL,
82+
git_url: GitURL,
8383
git_repo: GitProject,
8484
):
8585
url = url.format(local_repo=git_repo.dir)
86-
git_location.url = git_location.url.format(local_repo=git_repo.dir)
86+
git_url.url = git_url.url.format(local_repo=git_repo.dir)
8787

8888
assert GitURL.is_valid(url) == is_valid, f"{url} compatibility should be {is_valid}"
89-
assert GitURL(url) == git_location
89+
assert GitURL(url) == git_url
9090

9191

9292
class GitURLKwargs(typing.TypedDict):
@@ -96,7 +96,7 @@ class GitURLKwargs(typing.TypedDict):
9696
class GitURLKwargsFixture(typing.NamedTuple):
9797
url: str
9898
is_valid: bool
99-
git_location_kwargs: GitURLKwargs
99+
git_url_kwargs: GitURLKwargs
100100

101101

102102
#
@@ -110,75 +110,67 @@ class GitURLKwargsFixture(typing.NamedTuple):
110110
GitURLKwargsFixture(
111111
url="git+https://github.com/liuxinyu95/AlgoXY.git",
112112
is_valid=True,
113-
git_location_kwargs=GitURLKwargs(
114-
url="git+https://github.com/liuxinyu95/AlgoXY.git"
115-
),
113+
git_url_kwargs=GitURLKwargs(url="git+https://github.com/liuxinyu95/AlgoXY.git"),
116114
),
117115
GitURLKwargsFixture(
118116
url="git+ssh://git@github.com:tony/AlgoXY.git",
119117
is_valid=True,
120-
git_location_kwargs=GitURLKwargs(
121-
url="git+ssh://git@github.com:tony/AlgoXY.git"
122-
),
118+
git_url_kwargs=GitURLKwargs(url="git+ssh://git@github.com:tony/AlgoXY.git"),
123119
),
124120
GitURLKwargsFixture(
125121
url="git+file://{local_repo}",
126122
is_valid=True,
127-
git_location_kwargs=GitURLKwargs(url="git+file://{local_repo}"),
123+
git_url_kwargs=GitURLKwargs(url="git+file://{local_repo}"),
128124
),
129125
# Incompatible
130126
GitURLKwargsFixture(
131127
url="git+ssh://git@github.com/tony/AlgoXY.git",
132128
is_valid=True,
133-
git_location_kwargs=GitURLKwargs(
134-
url="git+ssh://git@github.com/tony/AlgoXY.git"
135-
),
129+
git_url_kwargs=GitURLKwargs(url="git+ssh://git@github.com/tony/AlgoXY.git"),
136130
),
137131
]
138132

139133

140134
@pytest.mark.parametrize(
141-
"url,is_valid,git_location_kwargs",
135+
"url,is_valid,git_url_kwargs",
142136
PIP_TEST_FIXTURES,
143137
)
144-
def test_git_location_extension_pip(
138+
def test_git_url_extension_pip(
145139
url: str,
146140
is_valid: bool,
147-
git_location_kwargs: GitURLKwargs,
141+
git_url_kwargs: GitURLKwargs,
148142
git_repo: GitProject,
149143
):
150144
class GitURLWithPip(GitURL):
151145
matchers = MatcherRegistry = MatcherRegistry(
152146
_matchers={m.label: m for m in [*DEFAULT_MATCHERS, *PIP_DEFAULT_MATCHERS]}
153147
)
154148

155-
git_location_kwargs["url"] = git_location_kwargs["url"].format(
156-
local_repo=git_repo.dir
157-
)
149+
git_url_kwargs["url"] = git_url_kwargs["url"].format(local_repo=git_repo.dir)
158150
url = url.format(local_repo=git_repo.dir)
159-
git_location = GitURLWithPip(**git_location_kwargs)
160-
git_location.url = git_location.url.format(local_repo=git_repo.dir)
151+
git_url = GitURLWithPip(**git_url_kwargs)
152+
git_url.url = git_url.url.format(local_repo=git_repo.dir)
161153

162154
assert (
163155
GitURL.is_valid(url) != is_valid
164156
), f"{url} compatibility should work with core, expects {not is_valid}"
165157
assert (
166158
GitURLWithPip.is_valid(url) == is_valid
167159
), f"{url} compatibility should be {is_valid}"
168-
assert GitURLWithPip(url) == git_location
160+
assert GitURLWithPip(url) == git_url
169161

170162

171163
class ToURLFixture(typing.NamedTuple):
172-
git_location: GitURL
164+
git_url: GitURL
173165
expected: str
174166

175167

176168
@pytest.mark.parametrize(
177-
"git_location,expected",
169+
"git_url,expected",
178170
[
179171
ToURLFixture(
180172
expected="https://github.com/vcs-python/libvcs.git",
181-
git_location=GitURL(
173+
git_url=GitURL(
182174
url="https://github.com/vcs-python/libvcs.git",
183175
scheme="https",
184176
hostname="github.com",
@@ -187,7 +179,7 @@ class ToURLFixture(typing.NamedTuple):
187179
),
188180
ToURLFixture(
189181
expected="https://github.com/vcs-python/libvcs",
190-
git_location=GitURL(
182+
git_url=GitURL(
191183
url="https://github.com/vcs-python/libvcs",
192184
scheme="https",
193185
hostname="github.com",
@@ -200,7 +192,7 @@ class ToURLFixture(typing.NamedTuple):
200192
#
201193
ToURLFixture(
202194
expected="git@github.com:liuxinyu95/AlgoXY.git",
203-
git_location=GitURL(
195+
git_url=GitURL(
204196
url="git@github.com:liuxinyu95/AlgoXY.git",
205197
scheme=None,
206198
hostname="github.com",
@@ -209,7 +201,7 @@ class ToURLFixture(typing.NamedTuple):
209201
),
210202
ToURLFixture(
211203
expected="git@github.com:vcs-python/libvcs.git",
212-
git_location=GitURL(
204+
git_url=GitURL(
213205
url="git@github.com:vcs-python/libvcs.git",
214206
scheme="https",
215207
hostname="github.com",
@@ -220,10 +212,10 @@ class ToURLFixture(typing.NamedTuple):
220212
)
221213
def test_git_to_url(
222214
expected: str,
223-
git_location: GitURL,
215+
git_url: GitURL,
224216
git_repo: GitProject,
225217
):
226218
"""Test GitURL.to_url()"""
227-
git_location.url = git_location.url.format(local_repo=git_repo.dir)
219+
git_url.url = git_url.url.format(local_repo=git_repo.dir)
228220

229-
assert git_location.to_url() == expected
221+
assert git_url.to_url() == expected

0 commit comments

Comments
 (0)