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
|
@ -11,17 +11,17 @@ class TestExists(TestCase):
|
|||
|
||||
def test_basic(self):
|
||||
c = MagicMock()
|
||||
mod.exists(c, '/foo')
|
||||
c.run.assert_called_once_with('test -e /foo', warn=True)
|
||||
mod.exists(c, "/foo")
|
||||
c.run.assert_called_once_with("test -e /foo", warn=True)
|
||||
|
||||
|
||||
class TestHomePath(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
c = MagicMock()
|
||||
c.run.return_value.stdout = '/home/foo'
|
||||
path = mod.get_home_path(c, user='foo')
|
||||
self.assertEqual(path, '/home/foo')
|
||||
c.run.return_value.stdout = "/home/foo"
|
||||
path = mod.get_home_path(c, user="foo")
|
||||
self.assertEqual(path, "/home/foo")
|
||||
|
||||
|
||||
class TestIsSymlink(TestCase):
|
||||
|
@ -29,13 +29,13 @@ class TestIsSymlink(TestCase):
|
|||
def test_yes(self):
|
||||
c = MagicMock()
|
||||
c.run.return_value.failed = False
|
||||
self.assertTrue(mod.is_symlink(c, '/foo'))
|
||||
self.assertTrue(mod.is_symlink(c, "/foo"))
|
||||
c.run.assert_called_once_with('test -L "$(echo /foo)"', warn=True)
|
||||
|
||||
def test_no(self):
|
||||
c = MagicMock()
|
||||
c.run.return_value.failed = True
|
||||
self.assertFalse(mod.is_symlink(c, '/foo'))
|
||||
self.assertFalse(mod.is_symlink(c, "/foo"))
|
||||
c.run.assert_called_once_with('test -L "$(echo /foo)"', warn=True)
|
||||
|
||||
|
||||
|
@ -43,31 +43,39 @@ class TestMakoRenderer(TestCase):
|
|||
|
||||
def test_basic(self):
|
||||
c = MagicMock()
|
||||
renderer = mod.mako_renderer(c, env={'machine_is_live': True})
|
||||
renderer = mod.mako_renderer(c, env={"machine_is_live": True})
|
||||
here = os.path.dirname(__file__)
|
||||
path = os.path.join(here, 'files', 'bar', 'baz')
|
||||
path = os.path.join(here, "files", "bar", "baz")
|
||||
rendered = renderer(path, vars={})
|
||||
self.assertEqual(rendered, 'machine_is_live = True')
|
||||
self.assertEqual(rendered, "machine_is_live = True")
|
||||
|
||||
|
||||
class TestSetTimezone(TestCase):
|
||||
|
||||
def test_symlink(self):
|
||||
c = MagicMock()
|
||||
with patch.object(mod, 'is_symlink') as is_symlink:
|
||||
with patch.object(mod, "is_symlink") as is_symlink:
|
||||
is_symlink.return_value = True
|
||||
mod.set_timezone(c, 'America/Chicago')
|
||||
c.run.assert_has_calls([
|
||||
call("bash -c 'echo America/Chicago > /etc/timezone'"),
|
||||
])
|
||||
c.run.assert_called_with('ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime')
|
||||
mod.set_timezone(c, "America/Chicago")
|
||||
c.run.assert_has_calls(
|
||||
[
|
||||
call("bash -c 'echo America/Chicago > /etc/timezone'"),
|
||||
]
|
||||
)
|
||||
c.run.assert_called_with(
|
||||
"ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime"
|
||||
)
|
||||
|
||||
def test_not_symlink(self):
|
||||
c = MagicMock()
|
||||
with patch.object(mod, 'is_symlink') as is_symlink:
|
||||
with patch.object(mod, "is_symlink") as is_symlink:
|
||||
is_symlink.return_value = False
|
||||
mod.set_timezone(c, 'America/Chicago')
|
||||
c.run.assert_has_calls([
|
||||
call("bash -c 'echo America/Chicago > /etc/timezone'"),
|
||||
])
|
||||
c.run.assert_called_with('cp /usr/share/zoneinfo/America/Chicago /etc/localtime')
|
||||
mod.set_timezone(c, "America/Chicago")
|
||||
c.run.assert_has_calls(
|
||||
[
|
||||
call("bash -c 'echo America/Chicago > /etc/timezone'"),
|
||||
]
|
||||
)
|
||||
c.run.assert_called_with(
|
||||
"cp /usr/share/zoneinfo/America/Chicago /etc/localtime"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue