def test_new_deck_points(): # Checks that the correct deck calibration points are being used # if feature_flag is set (or not) advs.set_adv_setting('deckCalibrationDots', True) calibration_points = get_calibration_points() expected_points1 = expected_points() # Check that old calibration points are used in cli assert calibration_points[1] == (12.13, 6.0) assert calibration_points[2] == (380.87, 6.0) assert calibration_points[3] == (12.13, 351.5) # Check that endpoints are now using slot 7 for dots assert expected_points1['1'] == (12.13, 6.0) assert expected_points1['2'] == (380.87, 6.0) assert expected_points1['3'] == (12.13, 261.0) advs.set_adv_setting('deckCalibrationDots', False) calibration_points2 = get_calibration_points() expected_points2 = expected_points() # Check that new calibration points are used assert calibration_points2[1] == (12.13, 9.0) assert calibration_points2[2] == (380.87, 9.0) assert calibration_points2[3] == (12.13, 348.5) # Check that endpoints are now using slot 7 for crosses assert expected_points2['1'] == (12.13, 9.0) assert expected_points2['2'] == (380.87, 9.0) assert expected_points2['3'] == (12.13, 258.0)
def test_gantry_matrix_output( mock_config, hw_with_pipettes, loop, monkeypatch): # Check that the robot moves to the correct locations monkeypatch.setattr(hw_with_pipettes, 'config', mock_config) hw_with_pipettes.home() tool = dc_main.CLITool( get_calibration_points(), hw_with_pipettes, loop=loop) expected = [ [1.00, 0.00, 0.00, 0.00], [0.00, 0.99852725, 0.00, 0.5132547], [0.00, 0.00, 1.00, 0.00], [0.00, 0.00, 0.00, 1.00]] actual_points = { 1: (12.13, 9.5), 2: (380.87, 9.5), 3: (12.13, 348.5)} monkeypatch.setattr( dc_main.CLITool, 'actual_points', actual_points) assert tool.actual_points == actual_points tool.save_transform() assert np.allclose(expected, tool.current_transform)
def test_tip_probe(mock_config, loop, monkeypatch, hw_with_pipettes): # Test that tip probe returns successfully hw_with_pipettes.home() tool = dc_main.CLITool( get_calibration_points(), hw_with_pipettes, loop=loop) assert tool.hardware is hw_with_pipettes point_after = (10, 10, 10) output = tool.probe(point_after) assert output == 'Tip probe'
def test_tip_probe(mock_config, loop, monkeypatch, hardware): # Test that tip probe returns successfully # TODO (maybe): Figure out how to prevent the pytest loop fixture # from getting closed by the CLI tool on exit for API V2 tool = dc_main.CLITool(get_calibration_points(), hardware, loop=loop) assert tool.hardware is hardware point_after = (10, 10, 10) output = tool.probe(point_after) assert output == 'Tip probe'
def test_try_pickup_tip(mock_config, hw_with_pipettes, monkeypatch, loop): # Check that the robot moves to the correct locations hw_with_pipettes.home() monkeypatch.setattr(hw_with_pipettes._api, '_config', mock_config) tool = dc_main.CLITool(get_calibration_points(), hw_with_pipettes, loop=loop) output = tool.try_pickup_tip() assert output == 'Picked up tip!'
def test_move_output(mock_config, loop, monkeypatch, hardware): # Check that the robot moves to the correct locations # TODO: Make tests for both APIs tool = dc_main.CLITool(get_calibration_points(), hardware, loop=loop) assert tool.hardware is hardware # Move to all three calibration points expected_pts = tool._expected_points for pt in range(3): point = pt + 1 tool.validate(expected_pts[point], point, tool._current_mount) assert np.isclose(tool._position(), expected_pts[point]).all()
def test_try_pickup_tip(mock_config, hardware, monkeypatch, loop): # Check that the robot moves to the correct locations # TODO: Make tests for both APIs def fake_read_model(mount): return model2() monkeypatch.setattr(hardware._driver, 'read_pipette_model', fake_read_model) monkeypatch.setattr(hardware, 'config', mock_config) tool = dc_main.CLITool(get_calibration_points(), hardware, loop=loop) output = tool.try_pickup_tip() assert output == 'Picked up tip!'
def test_mount_offset(mock_config, hardware, loop, monkeypatch): # Check that mount offset gives the expected output when position is # slightly changed def fake_position(something): return [11.13, 8, 51.7] monkeypatch.setattr(hardware, 'config', mock_config) tool = dc_main.CLITool(get_calibration_points(), hardware, loop=loop) monkeypatch.setattr(dc_main.CLITool, '_position', fake_position) expected_offset = (1.0, 1.0, 0.0) tool.save_mount_offset() assert expected_offset == tool.hardware.config.mount_offset hardware.reset()
def test_mount_offset(mock_config, hw_with_pipettes, loop, monkeypatch): # Check that mount offset gives the expected output when position is # slightly changed def fake_position(something): return [-22.87, 8, 0] monkeypatch.setattr( hw_with_pipettes._obj_to_adapt, '_config', mock_config) hw_with_pipettes.home() tool = dc_main.CLITool( get_calibration_points(), hw_with_pipettes, loop=loop) monkeypatch.setattr( dc_main.CLITool, '_position', fake_position) expected_offset = (1.0, 1.0, 0.0) tool.save_mount_offset() assert expected_offset == tool.hardware.config.mount_offset