def test_auto_stop(self): """Test auto stop functionality.""" xknx = XKNX() cover = Cover( xknx, "TestCover", group_address_long="1/2/1", group_address_stop="1/2/2", travel_time_down=10, travel_time_up=10, ) with patch("xknx.devices.Cover.stop") as mock_stop, patch( "time.time") as mock_time: fut = asyncio.Future() fut.set_result(None) mock_stop.return_value = fut mock_time.return_value = 1517000000.0 # we start with state 0 - open covers (up) this is assumed immediately self.loop.run_until_complete(cover.set_position(0)) self.loop.run_until_complete(cover.set_position(50)) mock_time.return_value = 1517000001.0 self.loop.run_until_complete(cover.auto_stop_if_necessary()) mock_stop.assert_not_called() mock_time.return_value = 1517000005.0 self.loop.run_until_complete(cover.auto_stop_if_necessary()) mock_stop.assert_called_with() mock_stop.reset_mock()
def test_auto_stop(self): """Test auto stop functionality.""" xknx = XKNX(loop=self.loop) cover = Cover(xknx, 'TestCover', group_address_long='1/2/1', travel_time_down=10, travel_time_up=10) with patch('xknx.devices.Cover.stop') as mock_stop, patch( 'time.time') as mock_time: fut = asyncio.Future() fut.set_result(None) mock_stop.return_value = fut mock_time.return_value = 1517000000.0 self.loop.run_until_complete(asyncio.Task(cover.set_position(50))) mock_time.return_value = 1517000001.0 self.loop.run_until_complete( asyncio.Task(cover.auto_stop_if_necessary())) mock_stop.assert_not_called() mock_time.return_value = 1517000005.0 self.loop.run_until_complete( asyncio.Task(cover.auto_stop_if_necessary())) mock_stop.assert_called_with() mock_stop.reset_mock()
def test_auto_stop(self): """Test auto stop functionality.""" xknx = XKNX(loop=self.loop) cover = Cover( xknx, 'TestCover', group_address_long='1/2/1', travel_time_down=10, travel_time_up=10) with patch('xknx.devices.Cover.stop') as mock_stop, patch('time.time') as mock_time: fut = asyncio.Future() fut.set_result(None) mock_stop.return_value = fut mock_time.return_value = 1517000000.0 self.loop.run_until_complete(asyncio.Task(cover.set_position(50))) mock_time.return_value = 1517000001.0 self.loop.run_until_complete(asyncio.Task(cover.auto_stop_if_necessary())) mock_stop.assert_not_called() mock_time.return_value = 1517000005.0 self.loop.run_until_complete(asyncio.Task(cover.auto_stop_if_necessary())) mock_stop.assert_called_with() mock_stop.reset_mock()