Skip to content

Commit 2862106

Browse files
committed
added integration tests for consolidate
1 parent 9ef3682 commit 2862106

File tree

1 file changed

+390
-0
lines changed

1 file changed

+390
-0
lines changed

api/tests/opentrons/protocol_api_integration/test_transfer_with_liquid_classes.py

Lines changed: 390 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,393 @@ def test_order_of_water_transfer_steps_with_no_new_tips(
355355
]
356356
assert len(mock_manager.mock_calls) == len(expected_calls)
357357
assert mock_manager.mock_calls[2] == expected_calls[2]
358+
359+
360+
@pytest.mark.ot3_only
361+
@pytest.mark.parametrize(
362+
"simulated_protocol_context", [("2.23", "Flex")], indirect=True
363+
)
364+
def test_order_of_water_consolidate_steps(
365+
simulated_protocol_context: ProtocolContext,
366+
) -> None:
367+
"""It should run the consolidate steps without any errors.
368+
369+
This test only checks that various supported configurations for a consolidation
370+
analyze successfully. It doesn't check whether the steps are as expected.
371+
That will be covered in analysis snapshot tests.
372+
"""
373+
trash = simulated_protocol_context.load_trash_bin("A3")
374+
tiprack = simulated_protocol_context.load_labware(
375+
"opentrons_flex_96_tiprack_50ul", "D1"
376+
)
377+
pipette_50 = simulated_protocol_context.load_instrument(
378+
"flex_1channel_50", mount="left", tip_racks=[tiprack]
379+
)
380+
nest_plate = simulated_protocol_context.load_labware(
381+
"nest_96_wellplate_200ul_flat", "C3"
382+
)
383+
arma_plate = simulated_protocol_context.load_labware(
384+
"armadillo_96_wellplate_200ul_pcr_full_skirt", "C2"
385+
)
386+
387+
water = simulated_protocol_context.define_liquid_class("water")
388+
with (
389+
mock.patch.object(
390+
InstrumentCore,
391+
"load_liquid_class",
392+
side_effect=InstrumentCore.load_liquid_class,
393+
autospec=True,
394+
) as patched_load_liquid_class,
395+
mock.patch.object(
396+
InstrumentCore,
397+
"pick_up_tip",
398+
side_effect=InstrumentCore.pick_up_tip,
399+
autospec=True,
400+
) as patched_pick_up_tip,
401+
mock.patch.object(
402+
InstrumentCore,
403+
"aspirate_liquid_class",
404+
side_effect=InstrumentCore.aspirate_liquid_class,
405+
autospec=True,
406+
) as patched_aspirate,
407+
mock.patch.object(
408+
InstrumentCore,
409+
"dispense_liquid_class",
410+
side_effect=InstrumentCore.dispense_liquid_class,
411+
autospec=True,
412+
) as patched_dispense,
413+
mock.patch.object(
414+
InstrumentCore,
415+
"drop_tip_in_disposal_location",
416+
side_effect=InstrumentCore.drop_tip_in_disposal_location,
417+
autospec=True,
418+
) as patched_drop_tip,
419+
):
420+
mock_manager = mock.Mock()
421+
mock_manager.attach_mock(patched_pick_up_tip, "pick_up_tip")
422+
mock_manager.attach_mock(patched_load_liquid_class, "load_liquid_class")
423+
mock_manager.attach_mock(patched_aspirate, "aspirate_liquid_class")
424+
mock_manager.attach_mock(patched_dispense, "dispense_liquid_class")
425+
mock_manager.attach_mock(patched_drop_tip, "drop_tip_in_disposal_location")
426+
pipette_50.consolidate_liquid(
427+
liquid_class=water,
428+
volume=25,
429+
source=nest_plate.rows()[0][:2],
430+
dest=arma_plate.wells()[0],
431+
new_tip="once",
432+
trash_location=trash,
433+
)
434+
expected_calls = [
435+
mock.call.load_liquid_class(
436+
mock.ANY,
437+
name="water",
438+
transfer_properties=mock.ANY,
439+
tiprack_uri="opentrons/opentrons_flex_96_tiprack_50ul/1",
440+
),
441+
mock.call.pick_up_tip(
442+
mock.ANY,
443+
location=mock.ANY,
444+
well_core=mock.ANY,
445+
presses=mock.ANY,
446+
increment=mock.ANY,
447+
),
448+
mock.call.aspirate_liquid_class(
449+
mock.ANY,
450+
volume=25,
451+
source=mock.ANY,
452+
transfer_properties=mock.ANY,
453+
transfer_type=TransferType.MANY_TO_ONE,
454+
tip_contents=[LiquidAndAirGapPair(liquid=0, air_gap=0)],
455+
),
456+
mock.call.aspirate_liquid_class(
457+
mock.ANY,
458+
volume=25,
459+
source=mock.ANY,
460+
transfer_properties=mock.ANY,
461+
transfer_type=TransferType.MANY_TO_ONE,
462+
tip_contents=[LiquidAndAirGapPair(liquid=25, air_gap=0.1)],
463+
),
464+
mock.call.dispense_liquid_class(
465+
mock.ANY,
466+
volume=50,
467+
dest=mock.ANY,
468+
source=mock.ANY,
469+
transfer_properties=mock.ANY,
470+
transfer_type=TransferType.MANY_TO_ONE,
471+
tip_contents=[LiquidAndAirGapPair(liquid=50, air_gap=0)],
472+
add_final_air_gap=True,
473+
trash_location=mock.ANY,
474+
),
475+
mock.call.drop_tip_in_disposal_location(
476+
mock.ANY,
477+
disposal_location=trash,
478+
home_after=False,
479+
alternate_tip_drop=True,
480+
),
481+
]
482+
assert len(mock_manager.mock_calls) == 6
483+
assert mock_manager.mock_calls == expected_calls
484+
485+
486+
@pytest.mark.ot3_only
487+
@pytest.mark.parametrize(
488+
"simulated_protocol_context", [("2.23", "Flex")], indirect=True
489+
)
490+
def test_order_of_water_consolidate_steps_larger_volume_then_tip(
491+
simulated_protocol_context: ProtocolContext,
492+
) -> None:
493+
"""It should run the consolidate steps without any errors.
494+
495+
This test only checks that various supported configurations for a consolidation
496+
analyze successfully. It doesn't check whether the steps are as expected.
497+
That will be covered in analysis snapshot tests.
498+
"""
499+
trash = simulated_protocol_context.load_trash_bin("A3")
500+
tiprack = simulated_protocol_context.load_labware(
501+
"opentrons_flex_96_tiprack_50ul", "D1"
502+
)
503+
pipette_50 = simulated_protocol_context.load_instrument(
504+
"flex_1channel_50", mount="left", tip_racks=[tiprack]
505+
)
506+
nest_plate = simulated_protocol_context.load_labware(
507+
"nest_96_wellplate_200ul_flat", "C3"
508+
)
509+
arma_plate = simulated_protocol_context.load_labware(
510+
"armadillo_96_wellplate_200ul_pcr_full_skirt", "C2"
511+
)
512+
513+
water = simulated_protocol_context.define_liquid_class("water")
514+
with (
515+
mock.patch.object(
516+
InstrumentCore,
517+
"load_liquid_class",
518+
side_effect=InstrumentCore.load_liquid_class,
519+
autospec=True,
520+
) as patched_load_liquid_class,
521+
mock.patch.object(
522+
InstrumentCore,
523+
"pick_up_tip",
524+
side_effect=InstrumentCore.pick_up_tip,
525+
autospec=True,
526+
) as patched_pick_up_tip,
527+
mock.patch.object(
528+
InstrumentCore,
529+
"aspirate_liquid_class",
530+
side_effect=InstrumentCore.aspirate_liquid_class,
531+
autospec=True,
532+
) as patched_aspirate,
533+
mock.patch.object(
534+
InstrumentCore,
535+
"dispense_liquid_class",
536+
side_effect=InstrumentCore.dispense_liquid_class,
537+
autospec=True,
538+
) as patched_dispense,
539+
mock.patch.object(
540+
InstrumentCore,
541+
"drop_tip_in_disposal_location",
542+
side_effect=InstrumentCore.drop_tip_in_disposal_location,
543+
autospec=True,
544+
) as patched_drop_tip,
545+
):
546+
mock_manager = mock.Mock()
547+
mock_manager.attach_mock(patched_pick_up_tip, "pick_up_tip")
548+
mock_manager.attach_mock(patched_load_liquid_class, "load_liquid_class")
549+
mock_manager.attach_mock(patched_aspirate, "aspirate_liquid_class")
550+
mock_manager.attach_mock(patched_dispense, "dispense_liquid_class")
551+
mock_manager.attach_mock(patched_drop_tip, "drop_tip_in_disposal_location")
552+
pipette_50.consolidate_liquid(
553+
liquid_class=water,
554+
volume=30,
555+
source=nest_plate.rows()[0][:2],
556+
dest=arma_plate.wells()[0],
557+
new_tip="always",
558+
trash_location=trash,
559+
)
560+
expected_calls = [
561+
mock.call.load_liquid_class(
562+
mock.ANY,
563+
name="water",
564+
transfer_properties=mock.ANY,
565+
tiprack_uri="opentrons/opentrons_flex_96_tiprack_50ul/1",
566+
),
567+
mock.call.pick_up_tip(
568+
mock.ANY,
569+
location=mock.ANY,
570+
well_core=mock.ANY,
571+
presses=mock.ANY,
572+
increment=mock.ANY,
573+
),
574+
mock.call.aspirate_liquid_class(
575+
mock.ANY,
576+
volume=30,
577+
source=mock.ANY,
578+
transfer_properties=mock.ANY,
579+
transfer_type=TransferType.MANY_TO_ONE,
580+
tip_contents=[LiquidAndAirGapPair(liquid=0, air_gap=0)],
581+
),
582+
mock.call.dispense_liquid_class(
583+
mock.ANY,
584+
volume=30,
585+
dest=mock.ANY,
586+
source=mock.ANY,
587+
transfer_properties=mock.ANY,
588+
transfer_type=TransferType.MANY_TO_ONE,
589+
tip_contents=[LiquidAndAirGapPair(liquid=30, air_gap=0.1)],
590+
add_final_air_gap=True,
591+
trash_location=mock.ANY,
592+
),
593+
mock.call.drop_tip_in_disposal_location(
594+
mock.ANY,
595+
disposal_location=trash,
596+
home_after=False,
597+
alternate_tip_drop=True,
598+
),
599+
mock.call.pick_up_tip(
600+
mock.ANY,
601+
location=mock.ANY,
602+
well_core=mock.ANY,
603+
presses=mock.ANY,
604+
increment=mock.ANY,
605+
),
606+
mock.call.aspirate_liquid_class(
607+
mock.ANY,
608+
volume=30,
609+
source=mock.ANY,
610+
transfer_properties=mock.ANY,
611+
transfer_type=TransferType.MANY_TO_ONE,
612+
tip_contents=[LiquidAndAirGapPair(liquid=0, air_gap=0)],
613+
),
614+
mock.call.dispense_liquid_class(
615+
mock.ANY,
616+
volume=30,
617+
dest=mock.ANY,
618+
source=mock.ANY,
619+
transfer_properties=mock.ANY,
620+
transfer_type=TransferType.MANY_TO_ONE,
621+
tip_contents=[LiquidAndAirGapPair(liquid=30, air_gap=0.1)],
622+
add_final_air_gap=True,
623+
trash_location=mock.ANY,
624+
),
625+
mock.call.drop_tip_in_disposal_location(
626+
mock.ANY,
627+
disposal_location=trash,
628+
home_after=False,
629+
alternate_tip_drop=True,
630+
),
631+
]
632+
assert len(mock_manager.mock_calls) == 9
633+
assert mock_manager.mock_calls == expected_calls
634+
635+
636+
@pytest.mark.ot3_only
637+
@pytest.mark.parametrize(
638+
"simulated_protocol_context", [("2.23", "Flex")], indirect=True
639+
)
640+
def test_order_of_water_consolidate_steps_with_no_new_tips(
641+
simulated_protocol_context: ProtocolContext,
642+
) -> None:
643+
"""It should run the consolidate steps without any errors.
644+
645+
This test only checks that various supported configurations for a consolidation
646+
analyze successfully. It doesn't check whether the steps are as expected.
647+
That will be covered in analysis snapshot tests.
648+
"""
649+
trash = simulated_protocol_context.load_trash_bin("A3")
650+
tiprack = simulated_protocol_context.load_labware(
651+
"opentrons_flex_96_tiprack_50ul", "D1"
652+
)
653+
pipette_50 = simulated_protocol_context.load_instrument(
654+
"flex_1channel_50", mount="left", tip_racks=[tiprack]
655+
)
656+
nest_plate = simulated_protocol_context.load_labware(
657+
"nest_96_wellplate_200ul_flat", "C3"
658+
)
659+
arma_plate = simulated_protocol_context.load_labware(
660+
"armadillo_96_wellplate_200ul_pcr_full_skirt", "C2"
661+
)
662+
663+
water = simulated_protocol_context.define_liquid_class("water")
664+
pipette_50.pick_up_tip()
665+
with (
666+
mock.patch.object(
667+
InstrumentCore,
668+
"load_liquid_class",
669+
side_effect=InstrumentCore.load_liquid_class,
670+
autospec=True,
671+
) as patched_load_liquid_class,
672+
mock.patch.object(
673+
InstrumentCore,
674+
"pick_up_tip",
675+
side_effect=InstrumentCore.pick_up_tip,
676+
autospec=True,
677+
) as patched_pick_up_tip,
678+
mock.patch.object(
679+
InstrumentCore,
680+
"aspirate_liquid_class",
681+
side_effect=InstrumentCore.aspirate_liquid_class,
682+
autospec=True,
683+
) as patched_aspirate,
684+
mock.patch.object(
685+
InstrumentCore,
686+
"dispense_liquid_class",
687+
side_effect=InstrumentCore.dispense_liquid_class,
688+
autospec=True,
689+
) as patched_dispense,
690+
mock.patch.object(
691+
InstrumentCore,
692+
"drop_tip_in_disposal_location",
693+
side_effect=InstrumentCore.drop_tip_in_disposal_location,
694+
autospec=True,
695+
) as patched_drop_tip,
696+
):
697+
mock_manager = mock.Mock()
698+
mock_manager.attach_mock(patched_pick_up_tip, "pick_up_tip")
699+
mock_manager.attach_mock(patched_load_liquid_class, "load_liquid_class")
700+
mock_manager.attach_mock(patched_aspirate, "aspirate_liquid_class")
701+
mock_manager.attach_mock(patched_dispense, "dispense_liquid_class")
702+
mock_manager.attach_mock(patched_drop_tip, "drop_tip_in_disposal_location")
703+
pipette_50.consolidate_liquid(
704+
liquid_class=water,
705+
volume=25,
706+
source=nest_plate.rows()[0][:2],
707+
dest=arma_plate.wells()[0],
708+
new_tip="never",
709+
trash_location=trash,
710+
)
711+
expected_calls = [
712+
mock.call.load_liquid_class(
713+
mock.ANY,
714+
name="water",
715+
transfer_properties=mock.ANY,
716+
tiprack_uri="opentrons/opentrons_flex_96_tiprack_50ul/1",
717+
),
718+
mock.call.aspirate_liquid_class(
719+
mock.ANY,
720+
volume=25,
721+
source=mock.ANY,
722+
transfer_properties=mock.ANY,
723+
transfer_type=TransferType.MANY_TO_ONE,
724+
tip_contents=[LiquidAndAirGapPair(liquid=0, air_gap=0)],
725+
),
726+
mock.call.aspirate_liquid_class(
727+
mock.ANY,
728+
volume=25,
729+
source=mock.ANY,
730+
transfer_properties=mock.ANY,
731+
transfer_type=TransferType.MANY_TO_ONE,
732+
tip_contents=[LiquidAndAirGapPair(liquid=25, air_gap=0.1)],
733+
),
734+
mock.call.dispense_liquid_class(
735+
mock.ANY,
736+
volume=50,
737+
dest=mock.ANY,
738+
source=mock.ANY,
739+
transfer_properties=mock.ANY,
740+
transfer_type=TransferType.MANY_TO_ONE,
741+
tip_contents=[LiquidAndAirGapPair(liquid=50, air_gap=0)],
742+
add_final_air_gap=False,
743+
trash_location=mock.ANY,
744+
),
745+
]
746+
assert len(mock_manager.mock_calls) == 4
747+
assert mock_manager.mock_calls == expected_calls

0 commit comments

Comments
 (0)