Skip to content

Commit

Permalink
legacy command mapper and test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed Sep 26, 2024
1 parent 6f70d21 commit a213c1f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 35 deletions.
9 changes: 8 additions & 1 deletion api/src/opentrons/protocol_runner/legacy_command_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,17 @@ def _map_instrument_load(
# We just set this above, so we know it's not None.
started_at=succeeded_command.startedAt, # type: ignore[arg-type]
)
state_update = StateUpdate()
state_update.set_load_pipette(
pipette_id=pipette_id,
mount=succeeded_command.params.mount,
pipette_name=succeeded_command.params.pipetteName,
liquid_presence_detection=succeeded_command.params.liquidPresenceDetection,
)
succeed_action = pe_actions.SucceedCommandAction(
command=succeeded_command,
private_result=pipette_config_result,
state_update=StateUpdate(),
state_update=state_update,
)

self._command_count["LOAD_PIPETTE"] = count + 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
"""Test load pipette commands."""
from opentrons.protocol_engine.state.update_types import (
LoadPipetteUpdate,
PipetteConfigUpdate,
StateUpdate,
)
import pytest
from decoy import Decoy

Expand Down Expand Up @@ -84,4 +89,9 @@ async def test_configure_for_volume_implementation(
private=ConfigureForVolumePrivateResult(
pipette_id="pipette-id", serial_number="some number", config=config
),
state_update=StateUpdate(
pipette_config=PipetteConfigUpdate(
pipette_id="pipette-id", serial_number="some number", config=config
)
),
)
10 changes: 4 additions & 6 deletions api/tests/opentrons/protocol_engine/commands/test_drop_tip.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ async def test_drop_tip_implementation(
new_deck_point=DeckPoint(x=111, y=222, z=333),
),
pipette_tip_state=update_types.PipetteTipStateUpdate(
pipette_id="abc",
tip_geometry=None
)
pipette_id="abc", tip_geometry=None
),
),
)

Expand Down Expand Up @@ -202,8 +201,7 @@ async def test_drop_tip_with_alternating_locations(
new_deck_point=DeckPoint(x=111, y=222, z=333),
),
pipette_tip_state=update_types.PipetteTipStateUpdate(
pipette_id="abc",
tip_geometry=None
)
pipette_id="abc", tip_geometry=None
),
),
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Test drop tip in place commands."""
from opentrons.protocol_engine.state.update_types import PipetteTipStateUpdate, StateUpdate
from opentrons.protocol_engine.state.update_types import (
PipetteTipStateUpdate,
StateUpdate,
)
import pytest
from decoy import Decoy

Expand Down Expand Up @@ -30,13 +33,13 @@ async def test_drop_tip_implementation(

result = await subject.execute(params)

assert result == SuccessData(public=DropTipInPlaceResult(), private=None,
state_update=StateUpdate(
pipette_tip_state=PipetteTipStateUpdate(
pipette_id="abc",
tip_geometry=None
)
))
assert result == SuccessData(
public=DropTipInPlaceResult(),
private=None,
state_update=StateUpdate(
pipette_tip_state=PipetteTipStateUpdate(pipette_id="abc", tip_geometry=None)
),
)

decoy.verify(
await mock_tip_handler.drop_tip(pipette_id="abc", home_after=False),
Expand Down
32 changes: 22 additions & 10 deletions api/tests/opentrons/protocol_engine/commands/test_load_pipette.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Test load pipette commands."""
from opentrons.protocol_engine.state.update_types import LoadPipetteUpdate, StateUpdate
from opentrons.protocol_engine.state.update_types import (
LoadPipetteUpdate,
PipetteConfigUpdate,
StateUpdate,
)
import pytest
from decoy import Decoy

Expand Down Expand Up @@ -94,10 +98,14 @@ async def test_load_pipette_implementation(
pipette_name=PipetteNameType.P300_SINGLE,
mount=MountType.LEFT,
pipette_id="some id",
liquid_presence_detection=None
liquid_presence_detection=None,
),
pipette_config=config_data
)
pipette_config=PipetteConfigUpdate(
pipette_id="some id",
serial_number="some-serial-number",
config=config_data,
),
),
)


Expand Down Expand Up @@ -153,15 +161,19 @@ async def test_load_pipette_implementation_96_channel(
private=LoadPipettePrivateResult(
pipette_id="pipette-id", serial_number="some id", config=config_data
),
state_update=StateUpdate(
state_update=StateUpdate(
loaded_pipette=LoadPipetteUpdate(
pipette_name=PipetteNameType.P300_SINGLE,
pipette_name=PipetteNameType.P1000_96,
mount=MountType.LEFT,
pipette_id="some id",
liquid_presence_detection=None
pipette_id="pipette-id",
liquid_presence_detection=None,
),
pipette_config=config_data
)
pipette_config=PipetteConfigUpdate(
pipette_id="pipette-id",
serial_number="some id",
config=config_data,
),
),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ async def test_success(
),
pipette_tip_state=update_types.PipetteTipStateUpdate(
pipette_id="pipette-id",
tip_geometry=TipGeometry(length=42, diameter=5, volume=300)
)
tip_geometry=TipGeometry(length=42, diameter=5, volume=300),
),
),
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""Test unsafe drop tip in place commands."""
from opentrons.protocol_engine.state.update_types import PipetteTipStateUpdate, StateUpdate
from opentrons.protocol_engine.state.update_types import (
PipetteTipStateUpdate,
StateUpdate,
)
import pytest
from decoy import Decoy

Expand Down Expand Up @@ -45,13 +48,13 @@ async def test_drop_tip_implementation(

result = await subject.execute(params)

assert result == SuccessData(public=UnsafeDropTipInPlaceResult(), private=None,
state_update=StateUpdate(
pipette_tip_state=PipetteTipStateUpdate(
pipette_id="abc",
tip_geometry=None
)
))
assert result == SuccessData(
public=UnsafeDropTipInPlaceResult(),
private=None,
state_update=StateUpdate(
pipette_tip_state=PipetteTipStateUpdate(pipette_id="abc", tip_geometry=None)
),
)

decoy.verify(
await ot3_hardware_api.update_axis_position_estimations([Axis.P_L]),
Expand Down

0 comments on commit a213c1f

Please sign in to comment.