Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Apr 29, 2024
1 parent 3927333 commit 70c2348
Showing 1 changed file with 22 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,45 +45,40 @@ def subject(
),
],
)
@pytest.mark.parametrize("calibrate_mount", [MountType.LEFT, MountType.RIGHT])
async def test_calibration_move_to_location_implementation(
decoy: Decoy,
subject: MoveToMaintenancePositionImplementation,
state_view: StateView,
ot3_hardware_api: OT3API,
maintenance_position: MaintenancePosition,
verify_axes: Mapping[Axis, float],
calibrate_mount: MountType,
) -> None:
"""Command should get a move to target location and critical point and should verify move_to call."""
params = MoveToMaintenancePositionParams(
mount=MountType.LEFT, maintenancePosition=maintenance_position
mount=calibrate_mount, maintenancePosition=maintenance_position
)

decoy.when(
await ot3_hardware_api.gantry_position(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
).then_return(Point(x=1, y=2, z=3))

decoy.when(
ot3_hardware_api.get_instrument_max_height(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
).then_return(250)
).then_return(Point(x=1, y=2, z=250))

decoy.when(ot3_hardware_api.get_instrument_max_height(Mount.LEFT)).then_return(300)

result = await subject.execute(params=params)
assert result == MoveToMaintenancePositionResult()

decoy.verify(
await ot3_hardware_api.move_to(
mount=Mount.LEFT,
abs_position=Point(x=1, y=2, z=250),
critical_point=CriticalPoint.MOUNT,
),
await ot3_hardware_api.prepare_for_mount_movement(Mount.LEFT),
times=1,
)
decoy.verify(
await ot3_hardware_api.retract(Mount.LEFT),
times=1,
)

decoy.verify(
await ot3_hardware_api.move_to(
mount=Mount.LEFT,
Expand All @@ -92,21 +87,18 @@ async def test_calibration_move_to_location_implementation(
),
times=1,
)

decoy.verify(
await ot3_hardware_api.move_axes(
position=verify_axes,
),
times=1,
)

if params.maintenancePosition == MaintenancePosition.ATTACH_INSTRUMENT:
decoy.verify(
await ot3_hardware_api.disengage_axes(
list(verify_axes.keys()),
),
times=1,
)
decoy.verify(
await ot3_hardware_api.disengage_axes(
list(verify_axes.keys()),
),
times=1,
)


@pytest.mark.ot3_only
Expand All @@ -118,35 +110,26 @@ async def test_calibration_move_to_location_implementation_for_gripper(
) -> None:
"""Command should get a move to target location and critical point and should verify move_to call."""
params = MoveToMaintenancePositionParams(
mount=MountType.LEFT, maintenancePosition=MaintenancePosition.ATTACH_INSTRUMENT
mount=MountType.EXTENSION, maintenancePosition=MaintenancePosition.ATTACH_INSTRUMENT
)

decoy.when(
await ot3_hardware_api.gantry_position(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
).then_return(Point(x=1, y=2, z=3))

decoy.when(
ot3_hardware_api.get_instrument_max_height(
Mount.LEFT, critical_point=CriticalPoint.MOUNT
)
).then_return(250)

).then_return(Point(x=1, y=2, z=250))
decoy.when(ot3_hardware_api.get_instrument_max_height(Mount.LEFT)).then_return(300)

result = await subject.execute(params=params)
assert result == MoveToMaintenancePositionResult()

decoy.verify(
await ot3_hardware_api.move_to(
mount=Mount.LEFT,
abs_position=Point(x=1, y=2, z=250),
critical_point=CriticalPoint.MOUNT,
),
await ot3_hardware_api.prepare_for_mount_movement(Mount.LEFT),
times=1,
)
decoy.verify(
await ot3_hardware_api.retract(Mount.LEFT),
times=1,
)

decoy.verify(
await ot3_hardware_api.move_to(
mount=Mount.LEFT,
Expand Down

0 comments on commit 70c2348

Please sign in to comment.