Skip to content

Commit

Permalink
Fix some tests with the protocol engine related to protocol changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fsinapi committed Dec 1, 2023
1 parent 4f049f5 commit 1ac290e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion api/tests/opentrons/protocol_engine/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from opentrons.hardware_control import HardwareControlAPI, OT2HardwareControlAPI
from opentrons.hardware_control.api import API
from opentrons_shared_data.robot.dev_types import RobotTypeEnum

if TYPE_CHECKING:
from opentrons.hardware_control.ot3api import OT3API
Expand All @@ -44,7 +45,9 @@ def ot3_hardware_api(decoy: Decoy) -> OT3API:
try:
from opentrons.hardware_control.ot3api import OT3API

return decoy.mock(cls=OT3API)
mock = decoy.mock(cls=OT3API)
decoy.when(mock.get_robot_type()).then_return(RobotTypeEnum.FLEX)
return mock
except ImportError:
# TODO (tz, 9-23-22) Figure out a better way to use this fixture with OT-3 api only.
return None # type: ignore[return-value]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ async def test_move_labware_with_gripper(

decoy.when(state_store.config.use_virtual_gripper).then_return(False)
decoy.when(ot3_hardware_api.has_gripper()).then_return(True)
decoy.when(ot3_hardware_api._gripper_handler.is_ready_for_jaw_home()).then_return(
True
)
decoy.when(ot3_hardware_api.gripper_jaw_can_home()).then_return(True)

decoy.when(
await ot3_hardware_api.gantry_position(mount=OT3Mount.GRIPPER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from opentrons.protocol_engine.errors.exceptions import HardwareNotSupportedError

from opentrons.hardware_control.api import API
from opentrons_shared_data.robot.dev_types import RobotTypeEnum


@pytest.mark.ot3_only
Expand All @@ -16,6 +17,7 @@ def test_ensure_ot3_hardware(decoy: Decoy) -> None:
from opentrons.hardware_control.ot3api import OT3API

ot_3_hardware_api = decoy.mock(cls=OT3API)
decoy.when(ot_3_hardware_api.get_robot_type()).then_return(RobotTypeEnum.FLEX)
result = ensure_ot3_hardware(
ot_3_hardware_api,
)
Expand All @@ -28,6 +30,7 @@ def test_ensure_ot3_hardware(decoy: Decoy) -> None:
def test_ensure_ot3_hardware_raises_error(decoy: Decoy) -> None:
"""Should raise a HardwareNotSupportedError exception."""
ot_2_hardware_api = decoy.mock(cls=API)
decoy.when(ot_2_hardware_api.get_robot_type()).then_return(RobotTypeEnum.OT2)
with pytest.raises(HardwareNotSupportedError):
ensure_ot3_hardware(
ot_2_hardware_api,
Expand Down

0 comments on commit 1ac290e

Please sign in to comment.