def test_emergency_power_off_timeout(feedback_fn): mock_client = MockPowerClient() mock_client.feedback_fn = feedback_fn start = time.time() timeout = 1.0 with pytest.raises(power.CommandTimedOutError): power.power_off(mock_client, timeout_sec=timeout) dt = time.time() - start assert abs(dt - timeout) < 0.1
def disable_movement(self): logging.info("Depowering motors") power.power_off(self.__power_client) if self.__lease is not None: logging.info("Releasing lease") self.__lease_keep_alive.shutdown() self.__lease_client.return_lease(self.__lease) self.__lease = None if self.__estop_endpoint is not None: logging.info("Releasing estop") self.__estop_keepalive.stop() self.__estop_keepalive = None self.__estop_endpoint.stop() self.__estop_endpoint = None
def test_emergency_power_off_success(): mock_client = MockPowerClient() timeout = 1.0 mock_client.feedback_fn = lambda: time.sleep(timeout / 2.0) mock_client.response = power_pb2.STATUS_SUCCESS power.power_off(mock_client, timeout_sec=timeout)