Skip to content

Commit b1b4c5e

Browse files
test(api): Delete dead code: replace unused commands with placeholders (#17739)
## Overview This just deletes some dead code in the `opentrons/protocol_engine` tests to make the files marginally less gigantic. ## Test Plan and Hands on Testing Just CI. ## Changelog Historically, the interface to `PipetteStore` and friends had the caller give them a `SucceedCommandAction(command=...)`, with juicy details in the `command`. We have gradually been replacing that with `SucceedCommandAction(state_update=...)`, with juicy details in the `state_update`, and with `command` being ignored. (EXEC-639.) Many tests were still constructing meaningful `command` values, even though the code under test was just throwing them away. This PR replaces those values with terser placeholders. (`command=LoadModule(...)` is an exception—it is one of the last things that has not been ported to `state_update` yet.) ## Review requests None in particular. ## Risk assessment Very low.
1 parent f46defa commit b1b4c5e

File tree

3 files changed

+86
-437
lines changed

3 files changed

+86
-437
lines changed

api/tests/opentrons/protocol_engine/state/test_geometry_view.py

+21-192
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@
8686
)
8787
from opentrons.protocol_engine.commands import (
8888
CommandStatus,
89-
LoadLabwareResult,
90-
LoadLabware,
91-
LoadLabwareParams,
89+
Command,
9290
LoadModuleResult,
9391
LoadModule,
9492
LoadModuleParams,
@@ -129,6 +127,10 @@
129127
paddingOffset,
130128
mountOffset,
131129
)
130+
131+
from .command_fixtures import (
132+
create_comment_command,
133+
)
132134
from .inner_geometry_test_params import INNER_WELL_GEOMETRY_TEST_PARAMS
133135
from ..pipette_fixtures import get_default_nozzle_map
134136
from ..mock_circular_frusta import TEST_EXAMPLES as CIRCULAR_TEST_EXAMPLES
@@ -381,6 +383,11 @@ def my_cool_test(subject: GeometryView) -> None:
381383
)
382384

383385

386+
def _dummy_command() -> Command:
387+
"""Return a placeholder command."""
388+
return create_comment_command()
389+
390+
384391
def test_get_labware_parent_position(
385392
decoy: Decoy,
386393
mock_labware_view: LabwareView,
@@ -3093,23 +3100,7 @@ def test_get_offset_location_deck_slot(
30933100
) -> None:
30943101
"""Test if you can get the offset location of a labware in a deck slot."""
30953102
action = SucceedCommandAction(
3096-
command=LoadLabware(
3097-
id="load-labware-1",
3098-
createdAt=datetime.now(),
3099-
key="load-labware-1",
3100-
status=CommandStatus.SUCCEEDED,
3101-
result=LoadLabwareResult(
3102-
labwareId="labware-id-1",
3103-
definition=nice_labware_definition,
3104-
offsetId=None,
3105-
),
3106-
params=LoadLabwareParams(
3107-
location=DeckSlotLocation(slotName=DeckSlotName.SLOT_C2),
3108-
loadName=nice_labware_definition.parameters.loadName,
3109-
namespace=nice_labware_definition.namespace,
3110-
version=nice_labware_definition.version,
3111-
),
3112-
),
3103+
command=_dummy_command(),
31133104
state_update=StateUpdate(
31143105
loaded_labware=LoadedLabwareUpdate(
31153106
labware_id="labware-id-1",
@@ -3155,23 +3146,7 @@ def test_get_offset_location_module(
31553146
),
31563147
)
31573148
load_labware = SucceedCommandAction(
3158-
command=LoadLabware(
3159-
id="load-labware-1",
3160-
createdAt=datetime.now(),
3161-
key="load-labware-1",
3162-
status=CommandStatus.SUCCEEDED,
3163-
result=LoadLabwareResult(
3164-
labwareId="labware-id-1",
3165-
definition=nice_labware_definition,
3166-
offsetId=None,
3167-
),
3168-
params=LoadLabwareParams(
3169-
location=ModuleLocation(moduleId="module-id-1"),
3170-
loadName=nice_labware_definition.parameters.loadName,
3171-
namespace=nice_labware_definition.namespace,
3172-
version=nice_labware_definition.version,
3173-
),
3174-
),
3149+
command=_dummy_command(),
31753150
state_update=StateUpdate(
31763151
loaded_labware=LoadedLabwareUpdate(
31773152
labware_id="labware-id-1",
@@ -3226,23 +3201,7 @@ def test_get_offset_location_module_with_adapter(
32263201
),
32273202
)
32283203
load_adapter = SucceedCommandAction(
3229-
command=LoadLabware(
3230-
id="load-adapter-1",
3231-
createdAt=datetime.now(),
3232-
key="load-adapter-1",
3233-
status=CommandStatus.SUCCEEDED,
3234-
result=LoadLabwareResult(
3235-
labwareId="adapter-id-1",
3236-
definition=nice_adapter_definition,
3237-
offsetId=None,
3238-
),
3239-
params=LoadLabwareParams(
3240-
location=ModuleLocation(moduleId="module-id-1"),
3241-
loadName=nice_adapter_definition.parameters.loadName,
3242-
namespace=nice_adapter_definition.namespace,
3243-
version=nice_adapter_definition.version,
3244-
),
3245-
),
3204+
command=_dummy_command(),
32463205
state_update=StateUpdate(
32473206
loaded_labware=LoadedLabwareUpdate(
32483207
labware_id="adapter-id-1",
@@ -3254,23 +3213,7 @@ def test_get_offset_location_module_with_adapter(
32543213
),
32553214
)
32563215
load_labware = SucceedCommandAction(
3257-
command=LoadLabware(
3258-
id="load-labware-1",
3259-
createdAt=datetime.now(),
3260-
key="load-labware-1",
3261-
status=CommandStatus.SUCCEEDED,
3262-
result=LoadLabwareResult(
3263-
labwareId="labware-id-1",
3264-
definition=nice_labware_definition,
3265-
offsetId=None,
3266-
),
3267-
params=LoadLabwareParams(
3268-
location=OnLabwareLocation(labwareId="adapter-id-1"),
3269-
loadName=nice_labware_definition.parameters.loadName,
3270-
namespace=nice_labware_definition.namespace,
3271-
version=nice_labware_definition.version,
3272-
),
3273-
),
3216+
command=_dummy_command(),
32743217
state_update=StateUpdate(
32753218
loaded_labware=LoadedLabwareUpdate(
32763219
labware_id="labware-id-1",
@@ -3307,23 +3250,7 @@ def test_get_offset_fails_with_off_deck_labware(
33073250
) -> None:
33083251
"""You cannot get the offset location for a labware loaded OFF_DECK."""
33093252
action = SucceedCommandAction(
3310-
command=LoadLabware(
3311-
id="load-labware-1",
3312-
createdAt=datetime.now(),
3313-
key="load-labware-1",
3314-
status=CommandStatus.SUCCEEDED,
3315-
result=LoadLabwareResult(
3316-
labwareId="labware-id-1",
3317-
definition=nice_labware_definition,
3318-
offsetId=None,
3319-
),
3320-
params=LoadLabwareParams(
3321-
location=OFF_DECK_LOCATION,
3322-
loadName=nice_labware_definition.parameters.loadName,
3323-
namespace=nice_labware_definition.namespace,
3324-
version=nice_labware_definition.version,
3325-
),
3326-
),
3253+
command=_dummy_command(),
33273254
state_update=StateUpdate(
33283255
loaded_labware=LoadedLabwareUpdate(
33293256
labware_id="labware-id-1",
@@ -3434,9 +3361,7 @@ def _find_volume_from_height_(index: int) -> None:
34343361

34353362
@pytest.mark.parametrize("frustum", CIRCULAR_TEST_EXAMPLES)
34363363
def test_circular_frustum_math_helpers(
3437-
decoy: Decoy,
34383364
frustum: Dict[str, List[float]],
3439-
subject: GeometryView,
34403365
) -> None:
34413366
"""Test both height and volume calculation within a given circular frustum."""
34423367
total_frustum_height = frustum["height"][0]
@@ -3794,23 +3719,7 @@ def test_get_location_sequence_deck_slot(
37943719
) -> None:
37953720
"""Test if you can get the location sequence of a labware in a deck slot."""
37963721
action = SucceedCommandAction(
3797-
command=LoadLabware(
3798-
id="load-labware-1",
3799-
createdAt=datetime.now(),
3800-
key="load-labware-1",
3801-
status=CommandStatus.SUCCEEDED,
3802-
result=LoadLabwareResult(
3803-
labwareId="labware-id-1",
3804-
definition=nice_labware_definition,
3805-
offsetId=None,
3806-
),
3807-
params=LoadLabwareParams(
3808-
location=DeckSlotLocation(slotName=DeckSlotName.SLOT_C2),
3809-
loadName=nice_labware_definition.parameters.loadName,
3810-
namespace=nice_labware_definition.namespace,
3811-
version=nice_labware_definition.version,
3812-
),
3813-
),
3722+
command=_dummy_command(),
38143723
state_update=StateUpdate(
38153724
loaded_labware=LoadedLabwareUpdate(
38163725
labware_id="labware-id-1",
@@ -3867,23 +3776,7 @@ def test_get_location_sequence_module(
38673776
),
38683777
)
38693778
load_labware = SucceedCommandAction(
3870-
command=LoadLabware(
3871-
id="load-labware-1",
3872-
createdAt=datetime.now(),
3873-
key="load-labware-1",
3874-
status=CommandStatus.SUCCEEDED,
3875-
result=LoadLabwareResult(
3876-
labwareId="labware-id-1",
3877-
definition=nice_labware_definition,
3878-
offsetId=None,
3879-
),
3880-
params=LoadLabwareParams(
3881-
location=ModuleLocation(moduleId="module-id-1"),
3882-
loadName=nice_labware_definition.parameters.loadName,
3883-
namespace=nice_labware_definition.namespace,
3884-
version=nice_labware_definition.version,
3885-
),
3886-
),
3779+
command=_dummy_command(),
38873780
state_update=StateUpdate(
38883781
loaded_labware=LoadedLabwareUpdate(
38893782
labware_id="labware-id-1",
@@ -3947,23 +3840,7 @@ def test_get_location_sequence_module_with_adapter(
39473840
),
39483841
)
39493842
load_adapter = SucceedCommandAction(
3950-
command=LoadLabware(
3951-
id="load-adapter-1",
3952-
createdAt=datetime.now(),
3953-
key="load-adapter-1",
3954-
status=CommandStatus.SUCCEEDED,
3955-
result=LoadLabwareResult(
3956-
labwareId="adapter-id-1",
3957-
definition=nice_adapter_definition,
3958-
offsetId=None,
3959-
),
3960-
params=LoadLabwareParams(
3961-
location=ModuleLocation(moduleId="module-id-1"),
3962-
loadName=nice_adapter_definition.parameters.loadName,
3963-
namespace=nice_adapter_definition.namespace,
3964-
version=nice_adapter_definition.version,
3965-
),
3966-
),
3843+
command=_dummy_command(),
39673844
state_update=StateUpdate(
39683845
loaded_labware=LoadedLabwareUpdate(
39693846
labware_id="adapter-id-1",
@@ -3975,23 +3852,7 @@ def test_get_location_sequence_module_with_adapter(
39753852
),
39763853
)
39773854
load_labware = SucceedCommandAction(
3978-
command=LoadLabware(
3979-
id="load-labware-1",
3980-
createdAt=datetime.now(),
3981-
key="load-labware-1",
3982-
status=CommandStatus.SUCCEEDED,
3983-
result=LoadLabwareResult(
3984-
labwareId="labware-id-1",
3985-
definition=nice_labware_definition,
3986-
offsetId=None,
3987-
),
3988-
params=LoadLabwareParams(
3989-
location=OnLabwareLocation(labwareId="adapter-id-1"),
3990-
loadName=nice_labware_definition.parameters.loadName,
3991-
namespace=nice_labware_definition.namespace,
3992-
version=nice_labware_definition.version,
3993-
),
3994-
),
3855+
command=_dummy_command(),
39953856
state_update=StateUpdate(
39963857
loaded_labware=LoadedLabwareUpdate(
39973858
labware_id="labware-id-1",
@@ -4028,23 +3889,7 @@ def test_get_location_sequence_off_deck(
40283889
) -> None:
40293890
"""You cannot get the location sequence for a labware loaded OFF_DECK."""
40303891
action = SucceedCommandAction(
4031-
command=LoadLabware(
4032-
id="load-labware-1",
4033-
createdAt=datetime.now(),
4034-
key="load-labware-1",
4035-
status=CommandStatus.SUCCEEDED,
4036-
result=LoadLabwareResult(
4037-
labwareId="labware-id-1",
4038-
definition=nice_labware_definition,
4039-
offsetId=None,
4040-
),
4041-
params=LoadLabwareParams(
4042-
location=OFF_DECK_LOCATION,
4043-
loadName=nice_labware_definition.parameters.loadName,
4044-
namespace=nice_labware_definition.namespace,
4045-
version=nice_labware_definition.version,
4046-
),
4047-
),
3892+
command=_dummy_command(),
40483893
state_update=StateUpdate(
40493894
loaded_labware=LoadedLabwareUpdate(
40503895
labware_id="labware-id-1",
@@ -4096,23 +3941,7 @@ def test_get_location_sequence_stacker_hopper(
40963941
),
40973942
)
40983943
load_labware = SucceedCommandAction(
4099-
command=LoadLabware(
4100-
id="load-labware-1",
4101-
createdAt=datetime.now(),
4102-
key="load-labware-1",
4103-
status=CommandStatus.SUCCEEDED,
4104-
result=LoadLabwareResult(
4105-
labwareId="labware-id-1",
4106-
definition=nice_labware_definition,
4107-
offsetId=None,
4108-
),
4109-
params=LoadLabwareParams(
4110-
location=ModuleLocation(moduleId="module-id-1"),
4111-
loadName=nice_labware_definition.parameters.loadName,
4112-
namespace=nice_labware_definition.namespace,
4113-
version=nice_labware_definition.version,
4114-
),
4115-
),
3944+
command=_dummy_command(),
41163945
state_update=StateUpdate(
41173946
loaded_labware=LoadedLabwareUpdate(
41183947
labware_id="labware-id-1",

api/tests/opentrons/protocol_engine/state/test_liquid_class_store_old.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
LiquidClassSchemaV1,
1111
)
1212
from opentrons.protocol_engine import actions
13-
from opentrons.protocol_engine.commands.load_liquid_class import LoadLiquidClass
1413
from opentrons.protocol_engine.state import update_types
1514
from opentrons.protocol_engine.state.liquid_classes import LiquidClassStore
1615
from opentrons.protocol_engine.types import LiquidClassRecord
1716

17+
from .command_fixtures import create_comment_command
18+
1819

1920
@pytest.fixture
2021
def subject() -> LiquidClassStore:
@@ -39,7 +40,7 @@ def test_handles_add_liquid_class(
3940

4041
subject.handle_action(
4142
actions.SucceedCommandAction(
42-
command=LoadLiquidClass.model_construct(), # type: ignore[call-arg]
43+
command=create_comment_command(),
4344
state_update=update_types.StateUpdate(
4445
liquid_class_loaded=update_types.LiquidClassLoadedUpdate(
4546
liquid_class_id="liquid-class-id",

0 commit comments

Comments
 (0)