get: test get_url raises exception if not a dvc repo

This commit is contained in:
Saugat Pachhai
2020-01-16 19:28:14 +05:45
parent f130e18e2c
commit aa7119a741
+10 -1
View File
@@ -6,7 +6,7 @@ import ruamel.yaml
import pytest
from dvc import api
from dvc.api import SummonError
from dvc.api import SummonError, UrlNotDvcRepoError
from dvc.compat import fspath
from dvc.exceptions import FileMissingError
from dvc.main import main
@@ -51,6 +51,15 @@ def test_get_url_external(erepo_dir, remote_url):
assert api.get_url("foo", repo=repo_url) == expected_url
def test_get_url_git_only_repo_throws_exception(tmp_dir, scm):
tmp_dir.scm_gen({"foo": "foo"}, commit="initial")
with pytest.raises(UrlNotDvcRepoError) as exc_info:
api.get_url("foo", fspath(tmp_dir))
assert fspath(tmp_dir) in str(exc_info)
@pytest.mark.parametrize("remote_url", all_remote_params, indirect=True)
def test_open(remote_url, tmp_dir, dvc):
run_dvc("remote", "add", "-d", "upstream", remote_url)