Fix slow WOL switch test (#10455)

pull/10465/head
Paulus Schoutsen 2017-11-08 03:38:17 -08:00 committed by Pascal Vizeli
parent db8510f110
commit 2e5b1e76ef
1 changed files with 4 additions and 1 deletions

View File

@ -6,7 +6,7 @@ from homeassistant.setup import setup_component
from homeassistant.const import STATE_ON, STATE_OFF from homeassistant.const import STATE_ON, STATE_OFF
import homeassistant.components.switch as switch import homeassistant.components.switch as switch
from tests.common import get_test_home_assistant from tests.common import get_test_home_assistant, mock_service
TEST_STATE = None TEST_STATE = None
@ -141,6 +141,7 @@ class TestWOLSwitch(unittest.TestCase):
}, },
} }
})) }))
calls = mock_service(self.hass, 'shell_command', 'turn_off_TARGET')
state = self.hass.states.get('switch.wake_on_lan') state = self.hass.states.get('switch.wake_on_lan')
self.assertEqual(STATE_OFF, state.state) self.assertEqual(STATE_OFF, state.state)
@ -152,6 +153,7 @@ class TestWOLSwitch(unittest.TestCase):
state = self.hass.states.get('switch.wake_on_lan') state = self.hass.states.get('switch.wake_on_lan')
self.assertEqual(STATE_ON, state.state) self.assertEqual(STATE_ON, state.state)
assert len(calls) == 0
TEST_STATE = False TEST_STATE = False
@ -160,6 +162,7 @@ class TestWOLSwitch(unittest.TestCase):
state = self.hass.states.get('switch.wake_on_lan') state = self.hass.states.get('switch.wake_on_lan')
self.assertEqual(STATE_OFF, state.state) self.assertEqual(STATE_OFF, state.state)
assert len(calls) == 1
@patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet) @patch('wakeonlan.wol.send_magic_packet', new=send_magic_packet)
@patch('subprocess.call', new=call) @patch('subprocess.call', new=call)