4
4
5
5
import pytest
6
6
from decoy import Decoy , matchers
7
+ from mock import AsyncMock , patch
8
+ from typing import Iterator
7
9
8
10
from opentrons_shared_data .errors .exceptions import PipetteOverpressureError
9
11
15
17
GantryMover ,
16
18
MovementHandler ,
17
19
)
20
+ from opentrons .protocol_engine .commands .movement_common import move_to_well
18
21
from opentrons .protocol_engine .commands .aspirate_while_tracking import (
19
22
AspirateWhileTrackingParams ,
20
23
AspirateWhileTrackingResult ,
36
39
WellOrigin ,
37
40
WellOffset ,
38
41
DeckPoint ,
42
+ WellLocation ,
39
43
)
40
44
from opentrons .protocol_engine .state import update_types
41
45
@@ -58,6 +62,12 @@ def pipetting(decoy: Decoy) -> PipettingHandler:
58
62
return decoy .mock (cls = PipettingHandler )
59
63
60
64
65
+ @pytest .fixture
66
+ def movement (decoy : Decoy ) -> MovementHandler :
67
+ """Get a mock in the shape of a MovementHandler."""
68
+ return decoy .mock (cls = MovementHandler )
69
+
70
+
61
71
@pytest .fixture
62
72
def subject (
63
73
pipetting : PipettingHandler ,
@@ -87,11 +97,11 @@ def subject(
87
97
(
88
98
CurrentWell (
89
99
pipette_id = "pipette-id-abc" ,
90
- labware_id = "labware-id-1 " ,
91
- well_name = "well-name-1 " ,
100
+ labware_id = "funky-labware " ,
101
+ well_name = "funky-well " ,
92
102
),
93
- "labware-id-1 " ,
94
- "well-name-1 " ,
103
+ "funky-labware " ,
104
+ "funky-well " ,
95
105
),
96
106
(
97
107
CurrentAddressableArea ("pipette-id-abc" , "addressable-area-1" ),
@@ -161,6 +171,26 @@ async def test_aspirate_while_tracking_implementation(
161
171
162
172
decoy .when (state_store .pipettes .get_current_location ()).then_return (location )
163
173
174
+ _well_location = LiquidHandlingWellLocation (
175
+ origin = WellOrigin .MENISCUS , offset = WellOffset (x = 0.0 , y = 0.0 , z = 1.0 )
176
+ )
177
+ _current_well = CurrentWell (
178
+ pipette_id = "pipette-id-abc" , labware_id = "funky-labware" , well_name = "funky-well"
179
+ )
180
+ decoy .when (
181
+ await subject ._movement .move_to_well (
182
+ pipette_id = "pipette-id-abc" ,
183
+ labware_id = "funky-labware" ,
184
+ well_name = "funky-well" ,
185
+ well_location = _well_location ,
186
+ current_well = _current_well ,
187
+ force_direct = False ,
188
+ minimum_z_height = None ,
189
+ speed = None ,
190
+ operation_volume = - 123.0 ,
191
+ ),
192
+ ).then_return (Point (x = 4 , y = 5 , z = 6 ))
193
+
164
194
result = await subject .execute (params = data )
165
195
166
196
if isinstance (location , CurrentWell ):
@@ -272,6 +302,26 @@ async def test_aspirate_raises_volume_error(
272
302
)
273
303
).then_raise (AssertionError ("blah blah" ))
274
304
305
+ _well_location = LiquidHandlingWellLocation (
306
+ origin = WellOrigin .MENISCUS , offset = WellOffset (x = 0.0 , y = 0.0 , z = 1.0 )
307
+ )
308
+ _current_well = CurrentWell (
309
+ pipette_id = "pipette-id-abc" , labware_id = "funky-labware" , well_name = "funky-well"
310
+ )
311
+ decoy .when (
312
+ await subject ._movement .move_to_well (
313
+ pipette_id = "pipette-id-abc" ,
314
+ labware_id = "funky-labware" ,
315
+ well_name = "funky-well" ,
316
+ well_location = _well_location ,
317
+ current_well = _current_well ,
318
+ force_direct = False ,
319
+ minimum_z_height = None ,
320
+ speed = None ,
321
+ operation_volume = - 50.0 ,
322
+ ),
323
+ ).then_return (Point (x = 4 , y = 5 , z = 6 ))
324
+
275
325
with pytest .raises (AssertionError ):
276
326
await subject .execute (data )
277
327
@@ -281,15 +331,15 @@ async def test_aspirate_raises_volume_error(
281
331
[
282
332
(
283
333
CurrentWell (
284
- pipette_id = "pipette-id" ,
285
- labware_id = "labware-id-1 " ,
286
- well_name = "well-name-1 " ,
334
+ pipette_id = "pipette-id-abc " ,
335
+ labware_id = "funky-labware " ,
336
+ well_name = "funky-well " ,
287
337
),
288
- "labware-id-1 " ,
289
- "well-name-1 " ,
338
+ "funky-labware " ,
339
+ "funky-well " ,
290
340
),
291
341
(None , None , None ),
292
- (CurrentAddressableArea ("pipette-id" , "addressable-area-1" ), None , None ),
342
+ (CurrentAddressableArea ("pipette-id-abc " , "addressable-area-1" ), None , None ),
293
343
],
294
344
)
295
345
async def test_overpressure_error (
@@ -305,7 +355,7 @@ async def test_overpressure_error(
305
355
stateupdateWell : str ,
306
356
) -> None :
307
357
"""It should return an overpressure error if the hardware API indicates that."""
308
- pipette_id = "pipette-id"
358
+ pipette_id = "pipette-id-abc "
309
359
310
360
position = Point (x = 1 , y = 2 , z = 3 )
311
361
@@ -315,13 +365,13 @@ async def test_overpressure_error(
315
365
state_store .geometry .get_nozzles_per_well (
316
366
labware_id = stateupdateLabware ,
317
367
target_well_name = stateupdateWell ,
318
- pipette_id = "pipette-id" ,
368
+ pipette_id = "pipette-id-abc " ,
319
369
)
320
370
).then_return (2 )
321
371
322
372
decoy .when (
323
373
state_store .geometry .get_wells_covered_by_pipette_with_active_well (
324
- stateupdateLabware , stateupdateWell , "pipette-id"
374
+ stateupdateLabware , stateupdateWell , "pipette-id-abc "
325
375
)
326
376
).then_return (["A3" , "A4" ])
327
377
well_location = LiquidHandlingWellLocation (
@@ -357,6 +407,26 @@ async def test_overpressure_error(
357
407
decoy .when (await gantry_mover .get_position (pipette_id )).then_return (position )
358
408
decoy .when (state_store .pipettes .get_current_location ()).then_return (location )
359
409
410
+ _well_location = LiquidHandlingWellLocation (
411
+ origin = WellOrigin .MENISCUS , offset = WellOffset (x = 0.0 , y = 0.0 , z = 1.0 )
412
+ )
413
+ _current_well = CurrentWell (
414
+ pipette_id = "pipette-id-abc" , labware_id = "funky-labware" , well_name = "funky-well"
415
+ )
416
+ decoy .when (
417
+ await subject ._movement .move_to_well (
418
+ pipette_id = pipette_id ,
419
+ labware_id = "funky-labware" ,
420
+ well_name = "funky-well" ,
421
+ well_location = _well_location ,
422
+ current_well = _current_well ,
423
+ force_direct = False ,
424
+ minimum_z_height = None ,
425
+ speed = None ,
426
+ operation_volume = - 50.0 ,
427
+ ),
428
+ ).then_return (Point (x = 4 , y = 5 , z = 6 ))
429
+
360
430
result = await subject .execute (data )
361
431
362
432
if isinstance (location , CurrentWell ):
@@ -374,7 +444,7 @@ async def test_overpressure_error(
374
444
volume_added = update_types .CLEAR ,
375
445
),
376
446
pipette_aspirated_fluid = update_types .PipetteUnknownFluidUpdate (
377
- pipette_id = "pipette-id"
447
+ pipette_id = "pipette-id-abc "
378
448
),
379
449
),
380
450
)
@@ -388,7 +458,7 @@ async def test_overpressure_error(
388
458
),
389
459
state_update = update_types .StateUpdate (
390
460
pipette_aspirated_fluid = update_types .PipetteUnknownFluidUpdate (
391
- pipette_id = "pipette-id"
461
+ pipette_id = "pipette-id-abc "
392
462
)
393
463
),
394
464
)
0 commit comments