async def test_home_all_api2(main_router, model): with mock.patch.object(model.instrument._context, 'home') as home: main_router.calibration_manager.home_all(model.instrument) home.assert_called_once() await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_move_to_top(main_router, model): with mock.patch.object(model.instrument._instrument, 'move_to') as move_to: main_router.calibration_manager.move_to(model.instrument, model.container) target = model.container._container.wells()[0].top() move_to.assert_called_with(target) await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_home_all_api1(main_router, model): with mock.patch.object(main_router.calibration_manager, '_hardware') as hardware: # noqa: e501 main_router.calibration_manager.home_all(model.instrument) hardware.home.assert_called_with() await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_return_tip(main_router, model): with mock.patch.object(model.instrument._instrument, 'return_tip') as return_tip: main_router.calibration_manager.return_tip(model.instrument) return_tip.assert_called_with() await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_drop_tip(main_router, model): with mock.patch.object(model.instrument._instrument, 'drop_tip') as drop_tip: main_router.calibration_manager.drop_tip(model.instrument, model.container) drop_tip.assert_called_with(model.container._container.wells()[0]) await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_move_to_front_api2(main_router, model): main_router.calibration_manager._hardware.home() with mock.patch.object(API, 'move_to') as patch: main_router.calibration_manager.move_to_front(model.instrument) patch.assert_called_with(Mount.RIGHT, Point(132.5, 90.5, 150), critical_point=CriticalPoint.NOZZLE) await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_pick_up_tip(main_router, model): with mock.patch.object(model.instrument._instrument, 'pick_up_tip') as pick_up_tip: # NOQA main_router.calibration_manager.pick_up_tip(model.instrument, model.container) pick_up_tip.assert_called_with(model.container._container[0]) await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_load_jog_save_run(main_router, protocol, protocol_file, dummy_db, monkeypatch): import tempfile temp = tempfile.gettempdir() monkeypatch.setenv('USER_DEFN_ROOT', temp) session = main_router.session_manager.create(name='<blank>', contents=protocol.text) await main_router.wait_until(state('session', 'loaded')) main_router.calibration_manager.move_to_front(session.instruments[0]) await main_router.wait_until(state('calibration', 'ready')) main_router.calibration_manager.tip_probe(session.instruments[0]) await main_router.wait_until(state('calibration', 'ready')) def instrument_procedure(index): def position(instrument): return pose_tracker.absolute(robot.poses, instrument._instrument) main_router.calibration_manager.move_to(session.instruments[index], session.containers[0]) pos = position(session.instruments[index]) acc = [] for axis in 'xyz': main_router.calibration_manager.jog(session.instruments[index], 1.0, axis) acc.append(subtract(position(session.instruments[index]), pos)) assert isclose(acc[0], [1.0, 0.0, 0.0]).all() assert isclose(acc[1], [1.0, 1.0, 0.0]).all() assert isclose(acc[2], [1.0, 1.0, 1.0]).all() pos = position(session.instruments[index]) main_router.calibration_manager.update_container_offset( container=session.containers[0], instrument=session.instruments[index]) # TODO (artyom 20171011): move home to a proper API endpoint robot.home() main_router.calibration_manager.move_to(session.instruments[index], session.containers[0]) # Last position should correspond to the value when # 'update_container_offset' was called assert isclose(pos, position(session.instruments[index])).all() instrument_procedure(1) instrument_procedure(0)
async def test_move_to_front_api1(main_router, model): robot = model.robot robot.home() with mock.patch( 'opentrons.util.calibration_functions.move_instrument_for_probing_prep' ) as patch: # NOQA(E501) main_router.calibration_manager.move_to_front(model.instrument) patch.assert_called_with(model.instrument._instrument, robot) await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_jog_api2(main_router, model): main_router.calibration_manager.home(model.instrument) with mock.patch.object(API, 'move_rel') as jog: for distance, axis in zip((1, 2, 3), 'xyz'): main_router.calibration_manager.jog(model.instrument, distance, axis) expected = [ mock.call(Mount.RIGHT, point, check_bounds=MotionChecks.HIGH) for point in [Point(x=1), Point( y=2), Point(z=3)] ] assert jog.mock_calls == expected await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_jog_api1(main_router, model): with mock.patch( 'opentrons.util.calibration_functions.jog_instrument') as jog: for distance, axis in zip((1, 2, 3), 'xyz'): main_router.calibration_manager.jog(model.instrument, distance, axis) expected = [ mock.call(instrument=model.instrument._instrument, distance=distance, axis=axis, robot=model.instrument._instrument.robot) for axis, distance in zip('xyz', (1, 2, 3)) ] assert jog.mock_calls == expected await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))
async def test_multi_single(main_router, protocol, protocol_file, dummy_db): robot.connect() robot.home() session = main_router.session_manager.create(name='<blank>', contents=protocol.text) await main_router.wait_until(state('session', 'loaded')) main_router.calibration_manager.move_to(session.instruments[0], session.containers[2])
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)
async def test_tip_probe(main_router, model): with mock.patch('opentrons.util.calibration_functions.probe_instrument' ) as probe_patch: probe_patch.return_value = (0, 0, 0) with mock.patch( 'opentrons.util.calibration_functions.update_instrument_config' ) as update_patch: main_router.calibration_manager.tip_probe(model.instrument) probe_patch.assert_called_with( instrument=model.instrument._instrument, robot=model.robot) update_patch.assert_called_with( instrument=model.instrument._instrument, measured_center=(0, 0, 0)) await main_router.wait_until(state('probing')) await main_router.wait_until(state('ready'))
async def test_home_api2(main_router, model): main_router.calibration_manager.home(model.instrument) await main_router.wait_until(state('moving')) await main_router.wait_until(state('ready'))