def model(robot, hardware, loop, request): # Use with pytest.mark.parametrize(’labware’, [some-labware-name]) # to have a different labware loaded as .container. If not passed, # defaults to the version-appropriate way to do 96 flat from opentrons.legacy_api.containers import load from opentrons.legacy_api.instruments.pipette import Pipette try: lw_name = request.getfixturevalue('labware') except Exception: lw_name = None if isinstance(hardware, hc.HardwareAPILike): ctx = ProtocolContext(loop=loop, hardware=hardware) pip = ctx.load_instrument('p300_single', 'right') loop.run_until_complete( hardware.cache_instruments({Mount.RIGHT: 'p300_single'})) instrument = models.Instrument(pip, context=ctx) plate = ctx.load_labware(lw_name or 'corning_96_wellplate_360ul_flat', 1) rob = hardware container = models.Container(plate, context=ctx) else: print("hardware is {}".format(hardware)) pipette = Pipette(robot, ul_per_mm=18.5, max_volume=300, mount='right') plate = load(robot, lw_name or '96-flat', '1') rob = robot instrument = models.Instrument(pipette) container = models.Container(plate) return namedtuple('model', 'robot instrument container')(robot=rob, instrument=instrument, container=container)
async def test_tip_probe_v2(main_router, model, monkeypatch): def fake_locate(mount, tip_length): assert mount == Mount[model.instrument.mount.upper()] assert tip_length is None return Point(0, 0, 0) def fake_update(mount, new_offset=None, from_tip_probe=None): assert mount == Mount[model.instrument.mount.upper()] if new_offset: assert new_offset == Point(0, 0, 0) elif from_tip_probe: assert from_tip_probe == Point(0, 0, 0) else: assert False, "fake_update called with no args" def fake_move(instrument): assert instrument == model.instrument def fake_add_tip(tip_length): assert tip_length == 51.7 def fake_remove_tip(): pass monkeypatch.setattr(main_router.calibration_manager._hardware._api, 'locate_tip_probe_center', fake_locate) monkeypatch.setattr(main_router.calibration_manager._hardware._api, 'update_instrument_offset', fake_update) monkeypatch.setattr(main_router.calibration_manager, 'move_to_front', fake_move) tr = labware.load('opentrons_96_tiprack_300ul', Location(Point(), 'test')) tr.tip_length = 2 model.instrument.tip_racks = [ models.Container(tr, [model.instrument._instrument], model.instrument._context) ] def new_fake_locate(mount, tip_length): assert tip_length == pytest.approx(2) return Point(0, 0, 0) monkeypatch.setattr(main_router.calibration_manager._hardware._api, 'locate_tip_probe_center', new_fake_locate) main_router.calibration_manager.tip_probe(model.instrument) await main_router.wait_until(state('ready')) def new_fake_locate2(mount, tip_length): assert tip_length == pytest.approx(2) return Point(0, 0, 0) monkeypatch.setattr(main_router.calibration_manager._hardware._api, 'locate_tip_probe_center', new_fake_locate2) main_router.calibration_manager.tip_probe(model.instrument)
def build_v1_model(r, lw_name): plate = load(r, lw_name or '96-flat', '1') tiprack = load(r, 'opentrons-tiprack-300ul', '2') pipette = Pipette(r, ul_per_mm=18.5, max_volume=300, mount='right', tip_racks=[tiprack]) instrument = models.Instrument(pipette) container = models.Container(plate) return namedtuple('model', 'robot instrument container')( robot=r, instrument=instrument, container=container, )
def model_with_trough(robot): from opentrons.legacy_api.containers import load from opentrons.legacy_api.instruments.pipette import Pipette pipette = Pipette(robot, ul_per_mm=18.5, max_volume=300, mount='right') plate = load(robot, 'trough-12row', '1') instrument = models.Instrument(pipette) container = models.Container(plate) return namedtuple('model', 'robot instrument container')(robot=robot, instrument=instrument, container=container)
def build_v2_model(h, lw_name, loop): ctx = ProtocolContext(loop=loop, hardware=h) loop.run_until_complete(h.cache_instruments({Mount.RIGHT: 'p300_single'})) tiprack = ctx.load_labware('opentrons_96_tiprack_300ul', '2') pip = ctx.load_instrument('p300_single', 'right', tip_racks=[tiprack]) instrument = models.Instrument(pip, context=ctx) plate = ctx.load_labware(lw_name or 'corning_96_wellplate_360ul_flat', 1) container = models.Container(plate, context=ctx) return namedtuple('model', 'robot instrument container')( robot=h, instrument=instrument, container=container, )