From 8ef61c0ba0372d7b71075ad17da35eb1ac3cd788 Mon Sep 17 00:00:00 2001 From: amitlissack Date: Fri, 19 Mar 2021 18:18:23 -0400 Subject: [PATCH] fix(api): Sleeps do not happen in thermocycler and tempdeck when simulating. closes #7506 --- api/src/opentrons/hardware_control/modules/tempdeck.py | 3 +++ .../opentrons/hardware_control/modules/thermocycler.py | 9 +++++++++ .../hardware_control/modules/test_hc_thermocycler.py | 10 ++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/src/opentrons/hardware_control/modules/tempdeck.py b/api/src/opentrons/hardware_control/modules/tempdeck.py index 2fc65759db2..10b32b88a5b 100644 --- a/api/src/opentrons/hardware_control/modules/tempdeck.py +++ b/api/src/opentrons/hardware_control/modules/tempdeck.py @@ -153,6 +153,9 @@ async def await_temperature(self, awaiting_temperature: float): Polls temperature module's temperature until the specified temperature is reached """ + if self.is_simulated: + return + await self.wait_for_is_running() async def _await_temperature(awaiting_temperature: float): diff --git a/api/src/opentrons/hardware_control/modules/thermocycler.py b/api/src/opentrons/hardware_control/modules/thermocycler.py index b2e6ee746a4..172bac17271 100644 --- a/api/src/opentrons/hardware_control/modules/thermocycler.py +++ b/api/src/opentrons/hardware_control/modules/thermocycler.py @@ -197,6 +197,9 @@ async def wait_for_lid_temp(self): Subject to change without a version bump. """ + if self.is_simulated: + return + while self._driver.lid_temp_status != 'holding at target': await asyncio.sleep(0.1) @@ -206,6 +209,9 @@ async def wait_for_temp(self): Subject to change without a version bump. """ + if self.is_simulated: + return + while self.status != 'holding at target': await asyncio.sleep(0.1) @@ -213,6 +219,9 @@ async def wait_for_hold(self, hold_time=0): """ This method returns only when hold time has elapsed """ + if self.is_simulated: + return + # If hold time is within the HOLD_TIME_FUZZY_SECONDS time gap, then, # because of the driver's status poller delays, it is impossible to # know for certain if self.hold_time holds the most recent value. diff --git a/api/tests/opentrons/hardware_control/modules/test_hc_thermocycler.py b/api/tests/opentrons/hardware_control/modules/test_hc_thermocycler.py index 2504b9900c2..c216ce73d26 100644 --- a/api/tests/opentrons/hardware_control/modules/test_hc_thermocycler.py +++ b/api/tests/opentrons/hardware_control/modules/test_hc_thermocycler.py @@ -1,6 +1,6 @@ import pytest import asyncio -from unittest import mock +import mock from opentrons.hardware_control import modules, ExecutionManager from opentrons.drivers.rpi_drivers.types import USBPort @@ -161,13 +161,11 @@ def async_return(result): set_temp_driver_mock.reset_mock() # Test hold_time < HOLD_TIME_FUZZY_SECONDS. Here we know - # that asyncio.sleep will be called with the direct hold + # that wait_for_hold will be called with the direct hold # time rather than increments of 0.1 - sleep_mock = mock.Mock() - async_sleep_mock = mock.Mock(side_effect=asyncio.coroutine(sleep_mock)) - monkeypatch.setattr(asyncio, 'sleep', async_sleep_mock) + hw_tc.wait_for_hold = mock.AsyncMock() await hw_tc.set_temperature(40, hold_time_seconds=2) - async_sleep_mock.assert_called_once_with(2) + hw_tc.wait_for_hold.assert_called_once_with(2) set_temp_driver_mock.assert_called_once_with(temp=40, hold_time=2, volume=None,