diff --git a/tests/func/test_api.py b/tests/func/test_api.py index 6ba3aef47..41cd0f743 100644 --- a/tests/func/test_api.py +++ b/tests/func/test_api.py @@ -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)