def test_tip_tracking_chain(local_test_pipette, robot):
    trash, tiprack1, tiprack2, plate, p200 = local_test_pipette
    # TODO (ben 20171130): revise this test to make more sense in the
    # context of required tip pick_up/drop sequencing, etc.

    total_tips_per_plate = 4

    tiprack1 = generate_plate(total_tips_per_plate, 2, (5, 5), (0, 0), 5)
    tiprack2 = generate_plate(total_tips_per_plate, 2, (5, 5), (0, 0), 5)
    robot._deck['1'].add(tiprack1, 'tiprack1')
    robot._deck['2'].add(tiprack2, 'tiprack2')

    p200 = Pipette(robot,
                   mount='right',
                   tip_racks=[tiprack1, tiprack2],
                   trash_container=tiprack1,
                   name='pipette-for-transfer-tests',
                   max_volume=200,
                   ul_per_mm=18.5)

    p200.move_to = mock.Mock()

    for _ in range(0, total_tips_per_plate * 2):
        p200.pick_up_tip()
        p200.tip_attached = False  # prior expectation, for test only

    expected = []
    for i in range(0, total_tips_per_plate):
        expected.extend(build_pick_up_tip(p200, tiprack1[i]))
    for i in range(0, total_tips_per_plate):
        expected.extend(build_pick_up_tip(p200, tiprack2[i]))

    assert p200.move_to.mock_calls == expected

    # test then when we go over the total number of tips,
    # Pipette raises a RuntimeWarning
    robot.clear_commands()
    p200.reset()
    for _ in range(0, total_tips_per_plate * 2):
        p200.pick_up_tip()
        p200.tip_attached = False  # prior expectation, for test only

    with pytest.raises(RuntimeWarning):
        p200.pick_up_tip()
def local_test_pipette(robot):
    trash = containers_load(robot, 'point', '1')
    tiprack1 = containers_load(robot, 'tiprack-10ul', '5')
    tiprack2 = containers_load(robot, 'tiprack-10ul', '8')

    plate = containers_load(robot, '96-flat', '4')

    p200 = Pipette(
        robot,
        ul_per_mm=18.5,
        trash_container=trash,
        tip_racks=[tiprack1, tiprack2],
        max_volume=200,
        min_volume=10,  # These are variable
        mount='left',
        channels=1,
        name='other-pipette-for-transfer-tests')

    p200.reset()

    p200.calibrate_plunger(top=0, bottom=10, blow_out=12, drop_tip=13)
    robot.home()
    return trash, tiprack1, tiprack2, plate, p200