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)
for value_id, value in node.values.items()}
print("\n\n\n")
print("FOUND NODE", node.product_name)
pprint(node_dict)
print("\n\n\n")
_LOGGER.info("FOUND NODE %s \n"
"%s", node.product_name, node_dict)
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
def test_print_node(self):
"""Test zwave print_config_parameter service."""
node1 = MockNode(node_id=14)
node2 = MockNode(node_id=15)
self.zwave_network.nodes = {14: node1, 15: node2}
"""Test zwave print_node_parameter service."""
node = MockNode(node_id=14)
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', {
const.ATTR_NODE_ID: 15,
const.ATTR_NODE_ID: 14
})
self.hass.block_till_done()
assert mock_pprint.called
assert len(mock_pprint.mock_calls) == 1
assert mock_pprint.mock_calls[0][1][0]['node_id'] == 15
self.assertIn("FOUND NODE ", mock_logger.output[1])
def test_set_wakeup(self):
"""Test zwave set_wakeup service."""