From fed0bfb2b359ff5c1ba1f1e67bffdc5cf36baf57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Tue, 8 Feb 2022 21:18:37 +0545 Subject: [PATCH] tests: add test for dvc.api.open with remote Covers #7341 --- tests/func/test_api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/func/test_api.py b/tests/func/test_api.py index 76b5e741c3..598ea7b28c 100644 --- a/tests/func/test_api.py +++ b/tests/func/test_api.py @@ -205,3 +205,17 @@ def test_get_url_subrepos(tmp_dir, scm, local_cloud): local_cloud / "37" / "b51d194a7513e45b56f6524f2d51f2" ) assert api.get_url("subrepo/bar") == expected_url + + +@pytest.mark.xfail(reason="https://github.com/iterative/dvc/issues/7341") +def test_open_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) + erepo_dir.dvc_gen({"dir": {"foo": "foo content"}}, commit="create file") + erepo_dir.dvc.push(remote="other") + remove(erepo_dir.dvc.odb.local.cache_dir) + + with api.open( + os.path.join("dir", "foo"), repo=erepo_dir.as_uri(), remote="other" + ) as fd: + assert fd.read() == "foo content"