From aa7119a74110208beb57fa4093f95123e1e1186d Mon Sep 17 00:00:00 2001 From: Saugat Pachhai Date: Thu, 16 Jan 2020 19:22:22 +0545 Subject: [PATCH] get: test get_url raises exception if not a dvc repo --- tests/func/test_api.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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)