pep8 format for tests/test_cli

This commit is contained in:
Yuming Zhu 2016-09-25 12:36:05 +00:00 committed by Mike McLean
parent 63ecac12eb
commit 75c6d2d28b
4 changed files with 17 additions and 9 deletions

View file

@ -30,7 +30,8 @@ class TestAddGroup(unittest.TestCase):
session = mock.MagicMock()
session.hasPerm.return_value = True
session.getTag.return_value = 'dsttag'
session.getTagGroups.return_value = [{'name': 'otherGroup', 'group_id': 'otherGroupId'}]
session.getTagGroups.return_value = [
{'name': 'otherGroup', 'group_id': 'otherGroupId'}]
# Run it and check immediate output
rv = cli.handle_add_group(options, session, arguments)
@ -58,7 +59,8 @@ class TestAddGroup(unittest.TestCase):
session = mock.MagicMock()
session.hasPerm.return_value = True
session.getTag.return_value = 'dsttag'
session.getTagGroups.return_value = [{'name': 'group', 'group_id': 'groupId'}]
session.getTagGroups.return_value = [
{'name': 'group', 'group_id': 'groupId'}]
# Run it and check immediate output
rv = cli.handle_add_group(options, session, arguments)
@ -77,7 +79,11 @@ class TestAddGroup(unittest.TestCase):
@mock.patch('sys.stdout', new_callable=stringio.StringIO)
@mock.patch('sys.stderr', new_callable=stringio.StringIO)
@mock.patch('koji_cli.activate_session')
def test_handle_add_group_help(self, activate_session_mock, stderr, stdout):
def test_handle_add_group_help(
self,
activate_session_mock,
stderr,
stdout):
arguments = []
options = mock.MagicMock()

View file

@ -50,7 +50,8 @@ class TestAddHost(unittest.TestCase):
@mock.patch('sys.stdout', new_callable=stringio.StringIO)
@mock.patch('koji_cli.activate_session')
def test_handle_add_host_no_krb_principal(self, activate_session_mock, stdout):
def test_handle_add_host_no_krb_principal(
self, activate_session_mock, stdout):
host = 'host'
host_id = 1
arches = ['arch1', 'arch2']
@ -161,7 +162,5 @@ class TestAddHost(unittest.TestCase):
session.addHost.assert_called_once_with(host, arches, **kwargs)
if __name__ == '__main__':
unittest.main()

View file

@ -9,7 +9,9 @@ import mock
import loadcli
cli = loadcli.cli
class TestListCommands(unittest.TestCase):
def setUp(self):
self.options = mock.MagicMock()
self.session = mock.MagicMock()

View file

@ -10,8 +10,8 @@ import loadcli
cli = loadcli.cli
class TestListCommands(unittest.TestCase):
def setUp(self):
self.options = mock.MagicMock()
self.session = mock.MagicMock()
@ -19,7 +19,7 @@ class TestListCommands(unittest.TestCase):
self.original_parser = cli.OptionParser
cli.OptionParser = mock.MagicMock()
self.parser = cli.OptionParser.return_value
cli.options = self.options # globals!!!
cli.options = self.options # globals!!!
def tearDown(self):
cli.OptionParser = self.original_parser
@ -53,7 +53,8 @@ class TestListCommands(unittest.TestCase):
# Finally, assert that things were called as we expected.
self.session.getTaskInfo.assert_called_once_with(1)
self.session.listTaskOutput.assert_called_once_with(1)
self.session.downloadTaskOutput.assert_called_once_with(1, 'runroot.log')
self.session.downloadTaskOutput.assert_called_once_with(
1, 'runroot.log')
self.session.runroot.assert_called_once_with(
tag, arch, command, repo_id=mock.ANY, weight=mock.ANY,
mounts=mock.ANY, packages=mock.ANY, skip_setarch=mock.ANY,