mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
api: update remote config tests
This commit is contained in:
committed by
Dave Berenbaum
parent
377d0c9d58
commit
603da1ca1e
@@ -31,6 +31,40 @@ def test_get_url_requires_dvc(tmp_dir, scm):
|
||||
api.get_url("foo", repo=f"file://{tmp_dir.as_posix()}")
|
||||
|
||||
|
||||
def test_get_url_from_remote(tmp_dir, erepo_dir, cloud, local_cloud):
|
||||
erepo_dir.add_remote(config=cloud.config, name="other")
|
||||
erepo_dir.add_remote(config=local_cloud.config, default=True)
|
||||
with erepo_dir.chdir():
|
||||
erepo_dir.dvc_gen("foo", "foo", commit="add foo")
|
||||
|
||||
# Using file url to force clone to tmp repo
|
||||
repo_url = f"file://{erepo_dir.as_posix()}"
|
||||
expected_rel_path = os.path.join(
|
||||
"files", "md5", "ac/bd18db4cc2f85cedef654fccc4a4d8"
|
||||
)
|
||||
|
||||
# Test default remote
|
||||
assert api.get_url("foo", repo=repo_url) == (local_cloud / expected_rel_path).url
|
||||
|
||||
# Test remote arg
|
||||
assert (
|
||||
api.get_url("foo", repo=repo_url, remote="other")
|
||||
== (cloud / expected_rel_path).url
|
||||
)
|
||||
|
||||
# Test config arg
|
||||
assert (
|
||||
api.get_url("foo", repo=repo_url, config={"core": {"remote": "other"}})
|
||||
== (cloud / expected_rel_path).url
|
||||
)
|
||||
|
||||
# Test remote_config arg
|
||||
assert (
|
||||
api.get_url("foo", repo=repo_url, remote_config={"url": cloud.url})
|
||||
== (cloud / expected_rel_path).url
|
||||
)
|
||||
|
||||
|
||||
def test_open_external(tmp_dir, erepo_dir, cloud):
|
||||
erepo_dir.add_remote(config=cloud.config)
|
||||
|
||||
@@ -253,3 +287,12 @@ def test_read_from_remote(tmp_dir, erepo_dir, cloud, local_cloud):
|
||||
)
|
||||
== "foo content"
|
||||
)
|
||||
|
||||
assert (
|
||||
api.read(
|
||||
os.path.join("dir", "foo"),
|
||||
repo=f"file://{erepo_dir.as_posix()}",
|
||||
remote_config={"url": cloud.url},
|
||||
)
|
||||
== "foo content"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user