示例#1
0
def test_well_init():
    slot = Location(Point(1, 2, 3), 1)
    well_name = 'circular_well_json'
    has_tip = False
    well1 = labware.Well(test_data[well_name], slot, well_name, has_tip)
    assert well1._diameter == test_data[well_name]['diameter']
    assert well1._length is None
    assert well1._width is None

    well2_name = 'rectangular_well_json'
    well2 = labware.Well(test_data[well2_name], slot, well2_name, has_tip)
    assert well2._diameter is None
    assert well2._length == test_data[well2_name]['xDimension']
    assert well2._width == test_data[well2_name]['yDimension']
示例#2
0
def test_from_center_cartesian():
    slot1 = Location(Point(10, 11, 12), 1)
    well_name = 'circular_well_json'
    has_tip = False
    well1 = labware.Well(test_data[well_name], slot1, well_name, has_tip,
                         MAX_SUPPORTED_VERSION)

    percent1_x = 1
    percent1_y = 1
    percent1_z = -0.5
    point1 = well1._from_center_cartesian(percent1_x, percent1_y, percent1_z)

    # slot.x + well.x + 1 * well.diamter/2
    expected_x = 10 + 40 + 15
    # slot.y + well.y + 1 * well.diamter/2
    expected_y = 11 + 50 + 15
    # slot.z + well.z + (1 - 0.5) * well.depth/2
    expected_z = 12 + 3 + 20 - 10

    assert point1.x == expected_x
    assert point1.y == expected_y
    assert point1.z == expected_z

    slot2 = Location(Point(13, 14, 15), 1)
    well2_name = 'rectangular_well_json'
    has_tip = False
    well2 = labware.Well(test_data[well2_name], slot2, well2_name, has_tip,
                         MAX_SUPPORTED_VERSION)
    percent2_x = -0.25
    percent2_y = 0.1
    percent2_z = 0.9
    point2 = well2._from_center_cartesian(percent2_x, percent2_y, percent2_z)

    # slot.x + well.x - 0.25 * well.length/2
    expected_x = 13 + 45 - 15
    # slot.y + well.y + 0.1 * well.width/2
    expected_y = 14 + 10 + 2.5
    # slot.z + well.z + (1 + 0.9) * well.depth/2
    expected_z = 15 + 22 + 19

    assert point2.x == expected_x
    assert point2.y == expected_y
    assert point2.z == expected_z
示例#3
0
def test_bottom():
    slot = Location(Point(7, 8, 9), 1)
    well_name = 'rectangular_well_json'
    has_tip = False
    well = labware.Well(test_data[well_name], slot, well_name, has_tip)
    well_data = test_data[well_name]
    expected_x = well_data['x'] + slot.point.x
    expected_y = well_data['y'] + slot.point.y
    expected_z = well_data['z'] + slot.point.z
    assert well.bottom() == Location(Point(expected_x, expected_y, expected_z),
                                     well)
示例#4
0
def test_top():
    slot = Location(Point(4, 5, 6), 1)
    well_name = 'circular_well_json'
    has_tip = False
    well = labware.Well(test_data[well_name], slot, well_name, has_tip)
    well_data = test_data[well_name]
    expected_x = well_data['x'] + slot.point.x
    expected_y = well_data['y'] + slot.point.y
    expected_z = well_data['z'] + well_data['depth'] + slot.point.z
    assert well.top() == Location(Point(expected_x, expected_y, expected_z),
                                  well)
示例#5
0
def test_well_parent():
    labware_name = 'corning_96_wellplate_360ul_flat'
    labware_def = labware.get_labware_definition(labware_name)
    lw = labware.Labware(labware_def, Location(Point(0, 0, 0), 'Test Slot'))
    parent = Location(Point(7, 8, 9), lw)
    well_name = 'circular_well_json'
    has_tip = True
    well = labware.Well(test_data[well_name], parent, well_name, has_tip)
    assert well.parent is lw
    assert well.top().labware is well
    assert well.top().labware.parent is lw
    assert well.bottom().labware is well
    assert well.bottom().labware.parent is lw
    assert well.center().labware is well
    assert well.center().labware.parent is lw
def test_touch_tip():
    location = Location(Point(1, 2, 3), 'deck')
    well = labware.Well(
        {
            'shape': 'circular',
            'depth': 40,
            'totalLiquidVolume': 100,
            'diameter': 30,
            'x': 40,
            'y': 50,
            'z': 3
        },
        parent=Location(Point(10, 20, 30), 1),
        has_tip=False,
        display_name='some well',
        api_level=MAX_SUPPORTED_VERSION)

    pipette_mock = mock.create_autospec(InstrumentContext, name='pipette_mock')
    mock_get_location_with_offset = mock.MagicMock(
        return_value=location, name='mock_get_location_with_offset')
    mock_get_well = mock.MagicMock(return_value=well, name='mock_get_well')
    mock_set_flow_rate = mock.MagicMock(name='mock_set_flow_rate')

    params = {
        'pipette': 'somePipetteId',
        'labware': 'someLabwareId',
        'well': 'someWell'
    }
    instruments = {'somePipetteId': pipette_mock}

    with mock.patch(
            'opentrons.protocol_api.execute_v3._get_location_with_offset',
            new=mock_get_location_with_offset):
        with mock.patch('opentrons.protocol_api.execute_v3._get_well',
                        new=mock_get_well):
            with mock.patch('opentrons.protocol_api.execute_v3._set_flow_rate',
                            new=mock_set_flow_rate):
                _touch_tip(instruments, mock.sentinel.loaded_labware, params)

    # note: for this fn, order of calls doesn't matter b/c
    # we don't have stateful stuff like flow_rate
    mock_get_location_with_offset.assert_called_once_with(
        mock.sentinel.loaded_labware, params)
    mock_get_well.assert_called_once_with(mock.sentinel.loaded_labware, params)
    assert pipette_mock.mock_calls == [
        mock.call.touch_tip(well, v_offset=-70.0)
    ]
示例#7
0
def test_move_to_well_with_optional_params():
    pipette_mock = mock.create_autospec(InstrumentContext)
    instruments = {'somePipetteId': pipette_mock}

    well = labware.Well(
        {
            'shape': 'circular',
            'depth': 40,
            'totalLiquidVolume': 100,
            'diameter': 30,
            'x': 40,
            'y': 50,
            'z': 3
        },
        parent=Location(Point(10, 20, 30), 1),
        has_tip=False,
        display_name='some well',
        api_level=MAX_SUPPORTED_VERSION)

    mock_get_well = mock.MagicMock(return_value=well, name='mock_get_well')

    params = {
        'pipette': 'somePipetteId',
        'labware': 'someLabwareId',
        'well': 'someWell',
        'offset': {
            'x': 10,
            'y': 11,
            'z': 12
        },
        'forceDirect': mock.sentinel.force_direct,
        'minimumZHeight': mock.sentinel.minimum_z_height
    }

    with mock.patch('opentrons.protocol_api.execute_v5._get_well',
                    new=mock_get_well):
        _move_to_well(instruments, mock.sentinel.loaded_labware, params)

    assert pipette_mock.mock_calls == [
        mock.call.move_to(well.bottom().move(Point(10, 11, 12)),
                          force_direct=mock.sentinel.force_direct,
                          minimum_z_height=mock.sentinel.minimum_z_height)
    ]

    assert mock_get_well.mock_calls == [
        mock.call(mock.sentinel.loaded_labware, params)
    ]