Bugfix: Zwave Print_node to logfile instead of console (#13302)

* Print to logfile instead of console

* Review changes

* Typo
This commit is contained in:
John Arild Berentsen 2018-04-05 11:14:15 +02:00 committed by GitHub
parent 692b2644c7
commit fe56844a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View File

@ -182,10 +182,8 @@ def nice_print_node(node):
node_dict['values'] = {value_id: _obj_to_dict(value) node_dict['values'] = {value_id: _obj_to_dict(value)
for value_id, value in node.values.items()} for value_id, value in node.values.items()}
print("\n\n\n") _LOGGER.info("FOUND NODE %s \n"
print("FOUND NODE", node.product_name) "%s", node.product_name, node_dict)
pprint(node_dict)
print("\n\n\n")
def get_config_value(node, value_index, tries=5): def get_config_value(node, value_index, tries=5):

View File

@ -1094,20 +1094,18 @@ class TestZWaveServices(unittest.TestCase):
assert mock_logger.info.mock_calls[0][1][3] == 2345 assert mock_logger.info.mock_calls[0][1][3] == 2345
def test_print_node(self): def test_print_node(self):
"""Test zwave print_config_parameter service.""" """Test zwave print_node_parameter service."""
node1 = MockNode(node_id=14) node = MockNode(node_id=14)
node2 = MockNode(node_id=15)
self.zwave_network.nodes = {14: node1, 15: node2}
with patch.object(zwave, 'pprint') as mock_pprint: self.zwave_network.nodes = {14: node}
with self.assertLogs(level='INFO') as mock_logger:
self.hass.services.call('zwave', 'print_node', { self.hass.services.call('zwave', 'print_node', {
const.ATTR_NODE_ID: 15, const.ATTR_NODE_ID: 14
}) })
self.hass.block_till_done() self.hass.block_till_done()
assert mock_pprint.called self.assertIn("FOUND NODE ", mock_logger.output[1])
assert len(mock_pprint.mock_calls) == 1
assert mock_pprint.mock_calls[0][1][0]['node_id'] == 15
def test_set_wakeup(self): def test_set_wakeup(self):
"""Test zwave set_wakeup service.""" """Test zwave set_wakeup service."""