Skip to content

Commit b1ff274

Browse files
committed
tests(git): Updates for remotes
1 parent 7065400 commit b1ff274

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

tests/test_git.py

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from libvcs import exc
1414
from libvcs.git import (
15+
FullRemoteDict,
1516
GitRemote,
1617
GitRepo,
1718
convert_pip_url as git_convert_pip_url,
@@ -26,6 +27,7 @@
2627

2728
RepoTestFactory = Callable[..., GitRepo]
2829
RepoTestFactoryLazyKwargs = Callable[..., dict]
30+
RepoTestFactoryRemotesLazyExpected = Callable[..., FullRemoteDict]
2931

3032

3133
@pytest.fixture(autouse=True, scope="module")
@@ -215,21 +217,61 @@ def progress_callback_spy(output, timestamp):
215217

216218
@pytest.mark.parametrize(
217219
# Postpone evaluation of options so fixture variables can interpolate
218-
"constructor,lazy_constructor_options",
220+
"constructor,lazy_constructor_options,lazy_remote_expected",
219221
[
220222
[
221223
GitRepo,
222224
lambda git_remote, repos_path, repo_name, **kwargs: {
223225
"url": f"file://{git_remote}",
224226
"repo_dir": repos_path / repo_name,
225227
},
228+
lambda git_remote, **kwargs: {"origin": f"file://{git_remote}"},
229+
],
230+
[
231+
GitRepo,
232+
lambda git_remote, repos_path, repo_name, **kwargs: {
233+
"url": f"file://{git_remote}",
234+
"repo_dir": repos_path / repo_name,
235+
"remotes": {"origin": f"file://{git_remote}"},
236+
},
237+
lambda git_remote, **kwargs: {"origin": f"file://{git_remote}"},
238+
],
239+
[
240+
GitRepo,
241+
lambda git_remote, repos_path, repo_name, **kwargs: {
242+
"url": f"file://{git_remote}",
243+
"repo_dir": repos_path / repo_name,
244+
"remotes": {
245+
"origin": f"file://{git_remote}",
246+
"second_remote": f"file://{git_remote}",
247+
},
248+
},
249+
lambda git_remote, **kwargs: {
250+
"origin": f"file://{git_remote}",
251+
"second_remote": f"file://{git_remote}",
252+
},
253+
],
254+
[
255+
GitRepo,
256+
lambda git_remote, repos_path, repo_name, **kwargs: {
257+
"url": f"file://{git_remote}",
258+
"repo_dir": repos_path / repo_name,
259+
"remotes": {
260+
"second_remote": f"file://{git_remote}",
261+
},
262+
},
263+
lambda git_remote, **kwargs: {
264+
"origin": f"file://{git_remote}",
265+
"second_remote": f"file://{git_remote}",
266+
},
226267
],
227268
[
228269
create_repo_from_pip_url,
229270
lambda git_remote, repos_path, repo_name, **kwargs: {
230271
"pip_url": f"git+file://{git_remote}",
231272
"repo_dir": repos_path / repo_name,
232273
},
274+
lambda git_remote, **kwargs: {"origin": f"file://{git_remote}"},
233275
],
234276
],
235277
)
@@ -238,16 +280,23 @@ def test_remotes(
238280
git_remote: pathlib.Path,
239281
constructor: RepoTestFactory,
240282
lazy_constructor_options: RepoTestFactoryLazyKwargs,
283+
lazy_remote_expected: RepoTestFactoryRemotesLazyExpected,
241284
):
242285
repo_name = "myrepo"
243286
remote_name = "myremote"
244287
remote_url = "https://localhost/my/git/repo.git"
245288

246289
git_repo: GitRepo = constructor(**lazy_constructor_options(**locals()))
247290
git_repo.obtain()
248-
git_repo.set_remote(name=remote_name, url=remote_url)
249291

250-
assert (remote_name, remote_url, remote_url) == git_repo.remote(remote_name)
292+
expected = lazy_remote_expected(**locals())
293+
assert len(expected.keys()) > 0
294+
for expected_remote_name, expected_remote_url in expected.items():
295+
assert (
296+
expected_remote_name,
297+
expected_remote_url,
298+
expected_remote_url,
299+
) == git_repo.remote(expected_remote_name)
251300

252301

253302
def test_git_get_url_and_rev_from_pip_url():

0 commit comments

Comments
 (0)