Files
dvc/tests/unit/remote/ssh.py
T
Ruslan Kuprieiev 5d381da5d9 ssh: change order of user configuration
Unfortunately this breaks backward compatibility, but we have to do it,
because current order is totally wrong. Configuring user with `dvc
remote modify myssh user` is an explicit action and should have higher
priority than implicit url. This is also important, since in the next
patch in this PR we will introduce support for `port` configuration,
that should also follow the same logic.

Signed-off-by: Ruslan Kuprieiev <[email protected]>
2019-01-08 10:12:43 +02:00

25 lines
654 B
Python

import getpass
from unittest import TestCase
from dvc.remote.ssh import RemoteSSH
class TestRemoteSSH(TestCase):
def test_user(self):
url = 'ssh://127.0.0.1:/path/to/dir'
config = {'url': url}
remote = RemoteSSH(None, config)
self.assertEqual(remote.user, getpass.getuser())
user = 'test1'
url = 'ssh://{}@127.0.0.1:/path/to/dir'.format(user)
config = {'url': url}
remote = RemoteSSH(None, config)
self.assertEqual(remote.user, user)
user = 'test2'
config['user'] = user
remote = RemoteSSH(None, config)
self.assertEqual(remote.user, user)