Stringify node_info.uuid as a precaution

Currently, utils:processing_logger_prefix() assumes node_info.uuid to be a
string.  However, a (broken) test case could encounter a TypeError logging:

   File "ironic_inspector/utils.py", line 103, in processing_logger_prefix
     return _('[node: %s]') % ' '.join(parts)
 TypeError: sequence item 0: expected string, MagicMock found

The patch purpose is to apply str(node_info.uuid) as a precaution.  This may
also help track where the real issue is with a broken test case.

Change-Id: I689f67c44a6304f7b296829fef3339872a4f6d36
This commit is contained in:
dparalen 2016-01-21 15:04:31 +01:00
parent a94e0d2d7f
commit c365e5403c
2 changed files with 6 additions and 1 deletions

View File

@ -243,6 +243,11 @@ class TestProcessingLogger(base.BaseTest):
utils.processing_logger_prefix(node_info=node_info,
data=data))
def test_prefix_uuid_not_str(self):
node_info = mock.Mock(uuid=None)
self.assertEqual('[node: None]',
utils.processing_logger_prefix(node_info=node_info))
def test_adapter_no_bmc(self):
CONF.set_override('log_bmc_address', False, 'processing')
node_info = mock.Mock(uuid='NNN')

View File

@ -88,7 +88,7 @@ def processing_logger_prefix(data=None, node_info=None):
data = data or {}
if node_info is not None:
parts.append(node_info.uuid)
parts.append(str(node_info.uuid))
pxe_mac = get_pxe_mac(data)
if pxe_mac: