26
26
from opentrons .protocol_engine .state import update_types
27
27
from opentrons .protocol_engine .state .state import StateView
28
28
from opentrons .protocol_engine .execution import MovementHandler , GantryMover , TipHandler
29
-
29
+ from opentrons .protocols .models import LabwareDefinition
30
+ import json
31
+ from opentrons_shared_data import load_shared_data
30
32
31
33
from opentrons .types import Point
32
34
@@ -82,13 +84,27 @@ def test_drop_tip_params_default_origin() -> None:
82
84
)
83
85
84
86
87
+ @pytest .fixture
88
+ def evotips_definition () -> LabwareDefinition :
89
+ """A fixturee of the evotips definition."""
90
+ # TODO (chb 2025-01-29): When we migrate all labware to v3 we can clean this up
91
+ return LabwareDefinition .model_validate (
92
+ json .loads (
93
+ load_shared_data (
94
+ "labware/definitions/3/evotips_opentrons_96_labware/1.json"
95
+ )
96
+ )
97
+ )
98
+
99
+
85
100
async def test_drop_tip_implementation (
86
101
decoy : Decoy ,
87
102
mock_state_view : StateView ,
88
103
mock_movement_handler : MovementHandler ,
89
104
mock_tip_handler : TipHandler ,
90
105
mock_model_utils : ModelUtils ,
91
106
gantry_mover : GantryMover ,
107
+ evotips_definition : LabwareDefinition ,
92
108
) -> None :
93
109
"""A DropTip command should have an execution implementation."""
94
110
subject = EvotipUnsealPipetteImplementation (
@@ -105,6 +121,9 @@ async def test_drop_tip_implementation(
105
121
wellName = "A3" ,
106
122
wellLocation = DropTipWellLocation (offset = WellOffset (x = 1 , y = 2 , z = 3 )),
107
123
)
124
+ decoy .when (mock_state_view .labware .get_definition ("123" )).then_return (
125
+ evotips_definition
126
+ )
108
127
109
128
decoy .when (
110
129
mock_state_view .pipettes .get_is_partially_configured (pipette_id = "abc" )
@@ -154,90 +173,14 @@ async def test_drop_tip_implementation(
154
173
),
155
174
),
156
175
)
157
-
158
176
decoy .verify (
159
- await mock_tip_handler .drop_tip (pipette_id = "abc" , home_after = True ),
160
- times = 1 ,
161
- )
162
-
163
-
164
- async def test_drop_tip_with_alternating_locations (
165
- decoy : Decoy ,
166
- mock_state_view : StateView ,
167
- mock_movement_handler : MovementHandler ,
168
- mock_tip_handler : TipHandler ,
169
- mock_model_utils : ModelUtils ,
170
- gantry_mover : GantryMover ,
171
- ) -> None :
172
- """It should drop tip at random location within the labware every time."""
173
- subject = EvotipUnsealPipetteImplementation (
174
- state_view = mock_state_view ,
175
- movement = mock_movement_handler ,
176
- tip_handler = mock_tip_handler ,
177
- model_utils = mock_model_utils ,
178
- gantry_mover = gantry_mover ,
179
- )
180
- params = EvotipUnsealPipetteParams (
181
- pipetteId = "abc" ,
182
- labwareId = "123" ,
183
- wellName = "A3" ,
184
- wellLocation = DropTipWellLocation (offset = WellOffset (x = 1 , y = 2 , z = 3 )),
185
- )
186
- drop_location = DropTipWellLocation (
187
- origin = DropTipWellOrigin .DEFAULT , offset = WellOffset (x = 10 , y = 20 , z = 30 )
188
- )
189
- decoy .when (
190
- mock_state_view .geometry .get_next_tip_drop_location (
191
- labware_id = "123" , well_name = "A3" , pipette_id = "abc"
192
- )
193
- ).then_return (drop_location )
194
-
195
- decoy .when (
196
- mock_state_view .pipettes .get_is_partially_configured (pipette_id = "abc" )
197
- ).then_return (False )
198
-
199
- decoy .when (
200
- mock_state_view .geometry .get_checked_tip_drop_location (
177
+ await mock_tip_handler .drop_tip (
201
178
pipette_id = "abc" ,
202
- labware_id = "123" ,
203
- well_location = drop_location ,
204
- partially_configured = False ,
205
- )
206
- ).then_return (WellLocation (offset = WellOffset (x = 4 , y = 5 , z = 6 )))
207
-
208
- decoy .when (
209
- await mock_movement_handler .move_to_well (
210
- pipette_id = "abc" ,
211
- labware_id = "123" ,
212
- well_name = "A3" ,
213
- well_location = WellLocation (offset = WellOffset (x = 4 , y = 5 , z = 6 )),
214
- current_well = None ,
215
- force_direct = False ,
216
- minimum_z_height = None ,
217
- speed = None ,
218
- operation_volume = None ,
219
- )
220
- ).then_return (Point (x = 111 , y = 222 , z = 333 ))
221
-
222
- result = await subject .execute (params )
223
- assert result == SuccessData (
224
- public = EvotipUnsealPipetteResult (position = DeckPoint (x = 111 , y = 222 , z = 333 )),
225
- state_update = update_types .StateUpdate (
226
- pipette_location = update_types .PipetteLocationUpdate (
227
- pipette_id = "abc" ,
228
- new_location = update_types .Well (
229
- labware_id = "123" ,
230
- well_name = "A3" ,
231
- ),
232
- new_deck_point = DeckPoint (x = 111 , y = 222 , z = 333 ),
233
- ),
234
- pipette_tip_state = update_types .PipetteTipStateUpdate (
235
- pipette_id = "abc" , tip_geometry = None
236
- ),
237
- pipette_aspirated_fluid = update_types .PipetteUnknownFluidUpdate (
238
- pipette_id = "abc"
239
- ),
179
+ home_after = None ,
180
+ do_not_ignore_tip_presence = False ,
181
+ ignore_plunger = True ,
240
182
),
183
+ times = 1 ,
241
184
)
242
185
243
186
@@ -248,6 +191,7 @@ async def test_tip_attached_error(
248
191
mock_tip_handler : TipHandler ,
249
192
mock_model_utils : ModelUtils ,
250
193
gantry_mover : GantryMover ,
194
+ evotips_definition : LabwareDefinition ,
251
195
) -> None :
252
196
"""A Evotip Unseal command should have an execution implementation."""
253
197
subject = EvotipUnsealPipetteImplementation (
@@ -264,6 +208,9 @@ async def test_tip_attached_error(
264
208
wellName = "A3" ,
265
209
wellLocation = DropTipWellLocation (offset = WellOffset (x = 1 , y = 2 , z = 3 )),
266
210
)
211
+ decoy .when (mock_state_view .labware .get_definition ("123" )).then_return (
212
+ evotips_definition
213
+ )
267
214
268
215
decoy .when (
269
216
mock_state_view .pipettes .get_is_partially_configured (pipette_id = "abc" )
@@ -292,51 +239,21 @@ async def test_tip_attached_error(
292
239
)
293
240
).then_return (Point (x = 111 , y = 222 , z = 333 ))
294
241
decoy .when (
295
- await mock_tip_handler .drop_tip (pipette_id = "abc" , home_after = None )
242
+ await mock_tip_handler .drop_tip (
243
+ pipette_id = "abc" ,
244
+ home_after = None ,
245
+ do_not_ignore_tip_presence = False ,
246
+ ignore_plunger = True ,
247
+ )
296
248
).then_raise (TipAttachedError ("Egads!" ))
297
249
298
250
decoy .when (mock_model_utils .generate_id ()).then_return ("error-id" )
299
251
decoy .when (mock_model_utils .get_timestamp ()).then_return (
300
252
datetime (year = 1 , month = 2 , day = 3 )
301
253
)
302
254
303
- result = await subject .execute (params )
304
-
305
- assert result == DefinedErrorData (
306
- public = StallOrCollisionError .model_construct (
307
- id = "error-id" ,
308
- createdAt = datetime (year = 1 , month = 2 , day = 3 ),
309
- wrappedErrors = [matchers .Anything ()],
310
- errorInfo = {"retryLocation" : (111 , 222 , 333 )},
311
- ),
312
- state_update = update_types .StateUpdate (
313
- pipette_location = update_types .PipetteLocationUpdate (
314
- pipette_id = "abc" ,
315
- new_location = update_types .Well (
316
- labware_id = "123" ,
317
- well_name = "A3" ,
318
- ),
319
- new_deck_point = DeckPoint (x = 111 , y = 222 , z = 333 ),
320
- ),
321
- pipette_aspirated_fluid = update_types .PipetteUnknownFluidUpdate (
322
- pipette_id = "abc"
323
- ),
324
- ),
325
- state_update_if_false_positive = update_types .StateUpdate (
326
- pipette_tip_state = update_types .PipetteTipStateUpdate (
327
- pipette_id = "abc" ,
328
- tip_geometry = None ,
329
- ),
330
- pipette_location = update_types .PipetteLocationUpdate (
331
- pipette_id = "abc" ,
332
- new_location = update_types .Well (
333
- labware_id = "123" ,
334
- well_name = "A3" ,
335
- ),
336
- new_deck_point = DeckPoint (x = 111 , y = 222 , z = 333 ),
337
- ),
338
- ),
339
- )
255
+ with pytest .raises (TipAttachedError ):
256
+ await subject .execute (params )
340
257
341
258
342
259
async def test_stall_error (
@@ -346,6 +263,7 @@ async def test_stall_error(
346
263
mock_tip_handler : TipHandler ,
347
264
mock_model_utils : ModelUtils ,
348
265
gantry_mover : GantryMover ,
266
+ evotips_definition : LabwareDefinition ,
349
267
) -> None :
350
268
"""A DropTip command should have an execution implementation."""
351
269
subject = EvotipUnsealPipetteImplementation (
@@ -362,6 +280,9 @@ async def test_stall_error(
362
280
wellName = "A3" ,
363
281
wellLocation = DropTipWellLocation (offset = WellOffset (x = 1 , y = 2 , z = 3 )),
364
282
)
283
+ decoy .when (mock_state_view .labware .get_definition ("123" )).then_return (
284
+ evotips_definition
285
+ )
365
286
366
287
decoy .when (
367
288
mock_state_view .pipettes .get_is_partially_configured (pipette_id = "abc" )
0 commit comments