summaryrefslogtreecommitdiff
path: root/ironic_python_agent/tests/unit
diff options
context:
space:
mode:
authorJohn L. Villalovos <john.l.villalovos@intel.com>2015-10-02 10:01:00 -0700
committerJohn L. Villalovos <john.l.villalovos@intel.com>2015-10-02 10:01:00 -0700
commitdcbba2b121da1525feff162aca17a8cc4adf55d6 (patch)
tree8e9c4c4c2a332adbbdd00ed80a3d40553c61e242 /ironic_python_agent/tests/unit
parent0144e79df5dab0837a55a981fa23298908af14cf (diff)
downloadironic-python-agent-dcbba2b121da1525feff162aca17a8cc4adf55d6.tar.gz
Enforce all flake8 rules except E129
Bring ironic-python-agent in line with the other ironic projects. Stop ignoring all E12* errors except E129 Stop ignoring E711 Change-Id: Icb9bc198473d1b5e807c20869eb2af7f4d7ac360
Diffstat (limited to 'ironic_python_agent/tests/unit')
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_base.py4
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_image.py17
-rw-r--r--ironic_python_agent/tests/unit/extensions/test_iscsi.py2
-rw-r--r--ironic_python_agent/tests/unit/test_errors.py2
-rw-r--r--ironic_python_agent/tests/unit/test_hardware.py57
-rw-r--r--ironic_python_agent/tests/unit/test_ironic_api_client.py4
-rw-r--r--ironic_python_agent/tests/unit/test_multi_hardware.py13
-rw-r--r--ironic_python_agent/tests/unit/test_utils.py7
8 files changed, 54 insertions, 52 deletions
diff --git a/ironic_python_agent/tests/unit/extensions/test_base.py b/ironic_python_agent/tests/unit/extensions/test_base.py
index c2f0b22d..5d68f155 100644
--- a/ironic_python_agent/tests/unit/extensions/test_base.py
+++ b/ironic_python_agent/tests/unit/extensions/test_base.py
@@ -134,7 +134,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
result.command_status)
self.assertEqual(None, result.command_error)
self.assertEqual({'result': 'fake_async_command: v1'},
- result.command_result)
+ result.command_result)
self.agent.force_heartbeat.assert_called_once_with()
def test_async_command_success_without_agent(self):
@@ -148,7 +148,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
result.command_status)
self.assertEqual(None, result.command_error)
self.assertEqual({'result': 'fake_async_command: v1'},
- result.command_result)
+ result.command_result)
def test_async_command_validation_failure(self):
self.assertRaises(errors.InvalidCommandParamsError,
diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py
index aa21ca0f..7d38e5ea 100644
--- a/ironic_python_agent/tests/unit/extensions/test_image.py
+++ b/ironic_python_agent/tests/unit/extensions/test_image.py
@@ -85,7 +85,7 @@ class TestImageExtension(test_base.BaseTestCase):
self.fake_dir + '/proc'),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-install %s"' %
- (self.fake_dir, self.fake_dev)), shell=True,
+ (self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-mkconfig -o '
@@ -130,7 +130,7 @@ class TestImageExtension(test_base.BaseTestCase):
self.fake_dir + '/boot/efi'),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-install %s"' %
- (self.fake_dir, self.fake_dev)), shell=True,
+ (self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-mkconfig -o '
@@ -159,8 +159,8 @@ class TestImageExtension(test_base.BaseTestCase):
@mock.patch.object(os, 'makedirs')
@mock.patch.object(image, '_get_partition')
def test__install_grub2_uefi_umount_fails(
- self, mock_get_part_uuid, mkdir_mock, environ_mock,
- mock_execute, mock_dispatch):
+ self, mock_get_part_uuid, mkdir_mock, environ_mock, mock_execute,
+ mock_dispatch):
mock_get_part_uuid.side_effect = [self.fake_root_part,
self.fake_efi_system_part]
@@ -186,7 +186,7 @@ class TestImageExtension(test_base.BaseTestCase):
self.fake_dir + '/boot/efi'),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-install %s"' %
- (self.fake_dir, self.fake_dev)), shell=True,
+ (self.fake_dir, self.fake_dev)), shell=True,
env_variables={'PATH': '/sbin:/bin'}),
mock.call(('chroot %s /bin/bash -c '
'"/usr/sbin/grub-mkconfig -o '
@@ -217,8 +217,7 @@ class TestImageExtension(test_base.BaseTestCase):
KNAME="test2" UUID="%s" TYPE="part"''' % self.fake_root_uuid)
mock_execute.side_effect = (None, None, [lsblk_output])
- root_part = image._get_partition(self.fake_dev,
- self.fake_root_uuid)
+ root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
self.assertEqual('/dev/test2', root_part)
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
delay_on_retry=True),
@@ -228,7 +227,7 @@ class TestImageExtension(test_base.BaseTestCase):
self.assertFalse(mock_dispatch.called)
def test__get_partition_no_device_found(self, mock_execute,
- mock_dispatch):
+ mock_dispatch):
lsblk_output = ('''KNAME="test" UUID="" TYPE="disk"
KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part"
KNAME="test2" UUID="" TYPE="part"''')
@@ -245,7 +244,7 @@ class TestImageExtension(test_base.BaseTestCase):
self.assertFalse(mock_dispatch.called)
def test__get_partition_command_fail(self, mock_execute,
- mock_dispatch):
+ mock_dispatch):
mock_execute.side_effect = (None, None,
processutils.ProcessExecutionError('boom'))
self.assertRaises(errors.CommandExecutionError,
diff --git a/ironic_python_agent/tests/unit/extensions/test_iscsi.py b/ironic_python_agent/tests/unit/extensions/test_iscsi.py
index 646a4e26..df1686f2 100644
--- a/ironic_python_agent/tests/unit/extensions/test_iscsi.py
+++ b/ironic_python_agent/tests/unit/extensions/test_iscsi.py
@@ -63,7 +63,7 @@ class TestISCSIExtension(test_base.BaseTestCase):
mock_dispatch.assert_called_once_with('get_os_install_device')
mock_wait_iscsi.assert_called_once_with()
self.assertEqual({'iscsi_target_iqn': self.fake_iqn},
- result.command_result)
+ result.command_result)
@mock.patch.object(os.path, 'exists', lambda x: False)
def test_start_iscsi_target_fail_wait_daemon(self, mock_execute,
diff --git a/ironic_python_agent/tests/unit/test_errors.py b/ironic_python_agent/tests/unit/test_errors.py
index 01918763..778f3a63 100644
--- a/ironic_python_agent/tests/unit/test_errors.py
+++ b/ironic_python_agent/tests/unit/test_errors.py
@@ -131,7 +131,7 @@ class TestErrors(test_base.BaseTestCase):
(errors.IncompatibleHardwareMethodError(), DEFAULT_DETAILS),
(errors.IncompatibleHardwareMethodError(DETAILS),
SAME_DETAILS),
- ]
+ ]
for (obj, check_details) in cases:
self._test_class(obj, check_details)
diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py
index a473ca0c..6805cc24 100644
--- a/ironic_python_agent/tests/unit/test_hardware.py
+++ b/ironic_python_agent/tests/unit/test_hardware.py
@@ -142,16 +142,16 @@ BLK_DEVICE_TEMPLATE_SMALL = (
)
SHRED_OUTPUT = (
- 'shred: /dev/sda: pass 1/2 (random)...\n'
- 'shred: /dev/sda: pass 1/2 (random)...4.9GiB/29GiB 17%\n'
- 'shred: /dev/sda: pass 1/2 (random)...15GiB/29GiB 51%\n'
- 'shred: /dev/sda: pass 1/2 (random)...20GiB/29GiB 69%\n'
- 'shred: /dev/sda: pass 1/2 (random)...29GiB/29GiB 100%\n'
- 'shred: /dev/sda: pass 2/2 (000000)...\n'
- 'shred: /dev/sda: pass 2/2 (000000)...4.9GiB/29GiB 17%\n'
- 'shred: /dev/sda: pass 2/2 (000000)...15GiB/29GiB 51%\n'
- 'shred: /dev/sda: pass 2/2 (000000)...20GiB/29GiB 69%\n'
- 'shred: /dev/sda: pass 2/2 (000000)...29GiB/29GiB 100%\n'
+ 'shred: /dev/sda: pass 1/2 (random)...\n'
+ 'shred: /dev/sda: pass 1/2 (random)...4.9GiB/29GiB 17%\n'
+ 'shred: /dev/sda: pass 1/2 (random)...15GiB/29GiB 51%\n'
+ 'shred: /dev/sda: pass 1/2 (random)...20GiB/29GiB 69%\n'
+ 'shred: /dev/sda: pass 1/2 (random)...29GiB/29GiB 100%\n'
+ 'shred: /dev/sda: pass 2/2 (000000)...\n'
+ 'shred: /dev/sda: pass 2/2 (000000)...4.9GiB/29GiB 17%\n'
+ 'shred: /dev/sda: pass 2/2 (000000)...15GiB/29GiB 51%\n'
+ 'shred: /dev/sda: pass 2/2 (000000)...20GiB/29GiB 69%\n'
+ 'shred: /dev/sda: pass 2/2 (000000)...29GiB/29GiB 100%\n'
)
@@ -229,11 +229,14 @@ class TestHardwareManagerLoading(test_base.BaseTestCase):
fake_ep = mock.Mock()
fake_ep.module_name = 'fake'
fake_ep.attrs = ['fake attrs']
- ext1 = extension.Extension('fake_generic0', fake_ep, None,
+ ext1 = extension.Extension(
+ 'fake_generic0', fake_ep, None,
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
- ext2 = extension.Extension('fake_mainline0', fake_ep, None,
+ ext2 = extension.Extension(
+ 'fake_mainline0', fake_ep, None,
FakeHardwareManager(hardware.HardwareSupport.MAINLINE))
- ext3 = extension.Extension('fake_generic1', fake_ep, None,
+ ext3 = extension.Extension(
+ 'fake_generic1', fake_ep, None,
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
self.correct_hw_manager = ext2.obj
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
@@ -596,10 +599,10 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
@mock.patch.object(utils, 'execute')
def test_erase_block_device_notsupported_shred(self, mocked_execute):
hdparm_output = HDPARM_INFO_TEMPLATE % {
- 'supported': 'not\tsupported',
- 'enabled': 'not\tenabled',
- 'frozen': 'not\tfrozen',
- 'enhanced_erase': 'not\tsupported: enhanced erase',
+ 'supported': 'not\tsupported',
+ 'enabled': 'not\tenabled',
+ 'frozen': 'not\tfrozen',
+ 'enhanced_erase': 'not\tsupported: enhanced erase',
}
mocked_execute.side_effect = [
@@ -654,7 +657,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
@mock.patch.object(os, 'readlink', autospec=True)
@mock.patch.object(os.path, 'exists', autospec=True)
def test__is_virtual_media_device_path_doesnt_exist(self, mocked_exists,
- mocked_link):
+ mocked_link):
mocked_exists.return_value = False
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
True)
@@ -670,8 +673,9 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
True)
res = self.hardware._shred_block_device(self.node, block_device)
self.assertFalse(res)
- mocked_execute.assert_called_once_with('shred', '--force', '--zero',
- '--verbose', '--iterations', '1', '/dev/sda')
+ mocked_execute.assert_called_once_with(
+ 'shred', '--force', '--zero', '--verbose', '--iterations', '1',
+ '/dev/sda')
@mock.patch.object(utils, 'execute')
def test_erase_block_device_shred_fail_processerror(self, mocked_execute):
@@ -680,8 +684,9 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
True)
res = self.hardware._shred_block_device(self.node, block_device)
self.assertFalse(res)
- mocked_execute.assert_called_once_with('shred', '--force', '--zero',
- '--verbose', '--iterations', '1', '/dev/sda')
+ mocked_execute.assert_called_once_with(
+ 'shred', '--force', '--zero', '--verbose', '--iterations', '1',
+ '/dev/sda')
@mock.patch.object(utils, 'execute')
def test_erase_block_device_ata_security_enabled(self, mocked_execute):
@@ -778,10 +783,10 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
expected_option,
'NULL', '/dev/sda')
- test_security_erase_option(self,
- '\tsupported: enhanced erase', '--security-erase-enhanced')
- test_security_erase_option(self,
- '\tnot\tsupported: enhanced erase', '--security-erase')
+ test_security_erase_option(
+ self, '\tsupported: enhanced erase', '--security-erase-enhanced')
+ test_security_erase_option(
+ self, '\tnot\tsupported: enhanced erase', '--security-erase')
@mock.patch.object(utils, 'execute')
def test_get_bmc_address(self, mocked_execute):
diff --git a/ironic_python_agent/tests/unit/test_ironic_api_client.py b/ironic_python_agent/tests/unit/test_ironic_api_client.py
index a17728cf..a197e08f 100644
--- a/ironic_python_agent/tests/unit/test_ironic_api_client.py
+++ b/ironic_python_agent/tests/unit/test_ironic_api_client.py
@@ -135,7 +135,7 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
node_uuid=None)
url = '{api_url}v1/drivers/{driver}/vendor_passthru/lookup'.format(
- api_url=API_URL, driver=DRIVER)
+ api_url=API_URL, driver=DRIVER)
request_args = self.api_client.session.request.call_args[0]
self.assertEqual(request_args[0], 'POST')
self.assertEqual(request_args[1], url)
@@ -266,7 +266,7 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
node_uuid='uuid')
url = '{api_url}v1/drivers/{driver}/vendor_passthru/lookup'.format(
- api_url=API_URL, driver=DRIVER)
+ api_url=API_URL, driver=DRIVER)
request_args = self.api_client.session.request.call_args[0]
self.assertEqual(request_args[0], 'POST')
self.assertEqual(request_args[1], url)
diff --git a/ironic_python_agent/tests/unit/test_multi_hardware.py b/ironic_python_agent/tests/unit/test_multi_hardware.py
index ba5e6259..7fb781c2 100644
--- a/ironic_python_agent/tests/unit/test_multi_hardware.py
+++ b/ironic_python_agent/tests/unit/test_multi_hardware.py
@@ -111,13 +111,12 @@ class TestMultipleHardwareManagerLoading(test_base.BaseTestCase):
fake_ep = mock.Mock()
fake_ep.module_name = 'fake'
fake_ep.attrs = ['fake attrs']
- self.generic_hwm = extension.Extension('fake_generic', fake_ep, None,
- FakeGenericHardwareManager())
- self.mainline_hwm = extension.Extension('fake_mainline', fake_ep, None,
- FakeMainlineHardwareManager())
- self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
- self.generic_hwm, self.mainline_hwm
- ])
+ self.generic_hwm = extension.Extension(
+ 'fake_generic', fake_ep, None, FakeGenericHardwareManager())
+ self.mainline_hwm = extension.Extension(
+ 'fake_mainline', fake_ep, None, FakeMainlineHardwareManager())
+ self.fake_ext_mgr = extension.ExtensionManager.make_test_instance(
+ [self.generic_hwm, self.mainline_hwm])
self.extension_mgr_patcher = mock.patch('stevedore.ExtensionManager')
self.mocked_extension_mgr = self.extension_mgr_patcher.start()
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py
index 849945b9..cb36f160 100644
--- a/ironic_python_agent/tests/unit/test_utils.py
+++ b/ironic_python_agent/tests/unit/test_utils.py
@@ -80,12 +80,11 @@ exit 1
fp = open(tmpfilename2, 'r')
runs = fp.read()
fp.close()
- self.assertNotEqual(runs.strip(), 'failure', 'stdin did not '
- 'always get passed '
- 'correctly')
+ self.assertNotEqual(runs.strip(), 'failure',
+ 'stdin did not always get passed correctly')
runs = int(runs.strip())
self.assertEqual(10, runs,
- 'Ran %d times instead of 10.' % (runs,))
+ 'Ran %d times instead of 10.' % (runs,))
finally:
os.unlink(tmpfilename)
os.unlink(tmpfilename2)