fix: format all code with black
and from now on should not deviate from that...
This commit is contained in:
parent
2bd094b10b
commit
147d2fd871
17 changed files with 298 additions and 216 deletions
|
@ -13,8 +13,8 @@ class TestCacheHostKey(TestCase):
|
|||
|
||||
# assume the first command runs okay
|
||||
c.run.return_value.failed = False
|
||||
mod.cache_host_key(c, 'example.com')
|
||||
c.run.assert_called_once_with('ssh example.com whoami', warn=True)
|
||||
mod.cache_host_key(c, "example.com")
|
||||
c.run.assert_called_once_with("ssh example.com whoami", warn=True)
|
||||
|
||||
def test_root_commands_not_allowed(self):
|
||||
c = MagicMock()
|
||||
|
@ -22,25 +22,27 @@ class TestCacheHostKey(TestCase):
|
|||
# assume the first command fails b/c "disallowed"
|
||||
c.run.return_value.failed = True
|
||||
c.run.return_value.stderr = "Disallowed command"
|
||||
mod.cache_host_key(c, 'example.com')
|
||||
c.run.assert_called_once_with('ssh example.com whoami', warn=True)
|
||||
mod.cache_host_key(c, "example.com")
|
||||
c.run.assert_called_once_with("ssh example.com whoami", warn=True)
|
||||
|
||||
def test_root_cache_key(self):
|
||||
c = MagicMock()
|
||||
|
||||
# first command fails; second command caches host key
|
||||
c.run.return_value.failed = True
|
||||
mod.cache_host_key(c, 'example.com')
|
||||
c.run.assert_has_calls([call('ssh example.com whoami', warn=True)])
|
||||
c.run.assert_called_with('ssh -o StrictHostKeyChecking=no example.com whoami', warn=True)
|
||||
mod.cache_host_key(c, "example.com")
|
||||
c.run.assert_has_calls([call("ssh example.com whoami", warn=True)])
|
||||
c.run.assert_called_with(
|
||||
"ssh -o StrictHostKeyChecking=no example.com whoami", warn=True
|
||||
)
|
||||
|
||||
def test_user_already_cached(self):
|
||||
c = MagicMock()
|
||||
|
||||
# assume the first command runs okay
|
||||
c.sudo.return_value.failed = False
|
||||
mod.cache_host_key(c, 'example.com', user='foo')
|
||||
c.sudo.assert_called_once_with('ssh example.com whoami', user='foo', warn=True)
|
||||
mod.cache_host_key(c, "example.com", user="foo")
|
||||
c.sudo.assert_called_once_with("ssh example.com whoami", user="foo", warn=True)
|
||||
|
||||
def test_user_commands_not_allowed(self):
|
||||
c = MagicMock()
|
||||
|
@ -48,15 +50,16 @@ class TestCacheHostKey(TestCase):
|
|||
# assume the first command fails b/c "disallowed"
|
||||
c.sudo.return_value.failed = True
|
||||
c.sudo.return_value.stderr = "Disallowed command"
|
||||
mod.cache_host_key(c, 'example.com', user='foo')
|
||||
c.sudo.assert_called_once_with('ssh example.com whoami', user='foo', warn=True)
|
||||
mod.cache_host_key(c, "example.com", user="foo")
|
||||
c.sudo.assert_called_once_with("ssh example.com whoami", user="foo", warn=True)
|
||||
|
||||
def test_user_cache_key(self):
|
||||
c = MagicMock()
|
||||
|
||||
# first command fails; second command caches host key
|
||||
c.sudo.return_value.failed = True
|
||||
mod.cache_host_key(c, 'example.com', user='foo')
|
||||
c.sudo.assert_has_calls([call('ssh example.com whoami', user='foo', warn=True)])
|
||||
c.sudo.assert_called_with('ssh -o StrictHostKeyChecking=no example.com whoami',
|
||||
user='foo', warn=True)
|
||||
mod.cache_host_key(c, "example.com", user="foo")
|
||||
c.sudo.assert_has_calls([call("ssh example.com whoami", user="foo", warn=True)])
|
||||
c.sudo.assert_called_with(
|
||||
"ssh -o StrictHostKeyChecking=no example.com whoami", user="foo", warn=True
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue