tests: test unsupported remote

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2018-07-19 22:56:53 +03:00
parent 2dabcd7d2f
commit 587cc08515
3 changed files with 15 additions and 2 deletions
+6
View File
@@ -11,3 +11,9 @@ class DvcException(Exception):
except Exception:
pass
super(DvcException, self).__init__(msg)
class UnsupportedRemoteError(DvcException):
def __init__(self, config, cause=None):
msg = "Remote '{}' is not supported.".format(config)
super(UnsupportedRemoteError, self).__init__(msg, cause=cause)
+2 -2
View File
@@ -6,7 +6,7 @@ from dvc.remote.ssh import RemoteSSH
from dvc.remote.azure import RemoteAzure
from dvc.config import Config
from dvc.exceptions import DvcException
from dvc.exceptions import UnsupportedRemoteError
REMOTES = [RemoteHDFS, RemoteSSH, RemoteS3, RemoteGS, RemoteAzure, RemoteLOCAL]
@@ -24,4 +24,4 @@ def Remote(project, config):
for r in REMOTES:
if r.supported(config):
return r(project, config)
raise DvcException('Remote \'{}\' is not supported.'.format(config))
raise UnsupportedRemoteError(str(config))
+7
View File
@@ -1,5 +1,8 @@
from dvc.main import main
from dvc.command.remote import CmdRemoteAdd
from dvc.exceptions import UnsupportedRemoteError
from dvc.remote import Remote
from dvc.config import Config
from tests.basic_env import TestDvc
@@ -34,3 +37,7 @@ class TestRemote(TestDvc):
cmd.configobj.write = None
ret = cmd.run()
self.assertNotEqual(ret, 0)
def test_unsupported(self):
with self.assertRaises(UnsupportedRemoteError):
Remote(self.dvc, {Config.SECTION_REMOTE_URL: 'unsupported://url')