示例#1
0
def test_LabwareDefinition__get_cartesian_vector_to_top_of_well__raises_error_if_no_plate_height():
    labware_definition = LabwareDefinition(
        **copy_dict_with_key_removed(GENERIC_LABWARE_DEFINITION_KWARGS, "plate_height")
    )
    with pytest.raises(CartesianVectorRequirePlateHeightError):
        labware_definition.get_cartesian_vector_to_top_of_well(
            0, 0, CoordinateSystem(0, 0, 0, False)
        )
示例#2
0
def test_LabwareDefinition__validate_hash_components_calls_super__and_raises_error_if_invalid_id(
    mocker,
):
    spied_validate = mocker.spy(DomainModel, "validate_hash_components")
    with pytest.raises(ValidationCollectionEmptyValueError) as e:
        LabwareDefinition().validate_hash_components(autopopulate=False)
    assert "uuid" in str(e)
    assert spied_validate.call_count == 1
示例#3
0
def test_LabwareDefinition__get_cartesian_vector_to_top_of_well(
    labware_definition_kwargs,
    row_idx,
    col_idx,
    coordinate_system,
    function_call_kwargs,
    expected_coordinates,
    test_description,
):
    labware_definition = LabwareDefinition(**labware_definition_kwargs)
    actual_coordinates = labware_definition.get_cartesian_vector_to_top_of_well(
        row_idx, col_idx, coordinate_system, **function_call_kwargs
    )
    assert actual_coordinates == expected_coordinates
示例#4
0
def test_LabwareDefinition__create_portrait_definition__rotates_standard_96_well():
    expected_plate_height = 14.2
    expected_row_spacing = 9
    expected_column_spacing = 9
    landscape = LabwareDefinition(
        row_count=8,
        column_count=12,
        plate_height=expected_plate_height,
        row_center_to_center_spacing=expected_row_spacing,
        column_center_to_center_spacing=expected_column_spacing,
    )
    portrait = landscape.create_portrait_definition()
    assert portrait.row_count == 12
    assert portrait.column_count == 8
    assert portrait.plate_height == expected_plate_height
    assert portrait.row_center_to_center_spacing == expected_row_spacing
    assert portrait.column_center_to_center_spacing == expected_column_spacing
示例#5
0
def test_LabwareDefinition__get_xy_coordinates_of_well__raises_error_if_definitions_missing(
    labware_definition_kwargs,
    row_idx,
    col_idx,
    function_call_kwargs,
    expected_error,
    test_description,
):
    labware_definition = LabwareDefinition(**labware_definition_kwargs)
    if expected_error is not None:
        with pytest.raises(expected_error):
            labware_definition.get_xy_coordinates_of_well(
                row_idx, col_idx, **function_call_kwargs
            )
    else:
        labware_definition.get_xy_coordinates_of_well(
            row_idx, col_idx, **function_call_kwargs
        )
示例#6
0
def test_LabwareDefinition__get_xy_coordinates_of_well(
    labware_definition_kwargs,
    row_idx,
    col_idx,
    x_offset,
    y_offset,
    expected_coordinates,
    test_description,
):
    labware_definition = LabwareDefinition(**labware_definition_kwargs)
    kwargs: Dict[str, Any] = dict()
    if x_offset is not None:
        kwargs["x_offset"] = x_offset
    if y_offset is not None:
        kwargs["y_offset"] = y_offset
    actual_coordinates = labware_definition.get_xy_coordinates_of_well(
        row_idx, col_idx, **kwargs
    )
    assert actual_coordinates == expected_coordinates
示例#7
0
def test_LabwareDefinition__create_portrait_definition__rotates_agilent_8_row_trough():
    expected_distance_to_liquid = 2
    expected_row_spacing = (
        9.01  # just to make it different than the 9 in the previous test
    )

    landscape = LabwareDefinition(
        row_count=8,
        center_of_a1=(14.29, 11.18),
        distance_to_liquid=expected_distance_to_liquid,
        row_center_to_center_spacing=expected_row_spacing,
    )
    portrait = landscape.create_portrait_definition()
    assert portrait.row_count is None
    assert portrait.column_count == 8
    assert portrait.center_of_a1 == (11.18, 14.29)
    assert portrait.distance_to_liquid == expected_distance_to_liquid
    assert portrait.column_center_to_center_spacing == expected_row_spacing
    assert portrait.row_center_to_center_spacing is None
示例#8
0
def test_LabwareDefinition_validate_row_and_column_counts__raises_error_if_column_invalid():
    m = LabwareDefinition(row_count=2, column_count="joe")
    with pytest.raises(ValidationCollectionCannotCoerceError):
        m.validate_row_and_column_counts()
示例#9
0
GENERIC_UUID = uuid.UUID("3d118df7-3cb1-484e-85cd-b06def38bc91")

GENERIC_LABWARE_DEFINITION_KWARGS: Dict[str, Any] = {
    "name": "12-well",
    "uuid": GENERIC_UUID,
    "row_count": 3,
    "column_count": 4,
    "center_of_a1": (8, 7),
    "plate_height": 13.4,
    "distance_to_liquid": 4,
    "row_center_to_center_spacing": 12,
    "column_center_to_center_spacing": 15,
}

GENERIC_LABWARE_DEFINITION = LabwareDefinition(
    **GENERIC_LABWARE_DEFINITION_KWARGS)

GENERIC_LABWARE_DEFINITION_2 = LabwareDefinition(name="96-well",
                                                 uuid=GENERIC_UUID,
                                                 row_count=3,
                                                 column_count=4)

GENERIC_BARCODED_SBS_LABWARE_KWARGS = {
    "uuid": GENERIC_UUID,
    "barcode": "AB9938",
    "labware_definition": GENERIC_LABWARE_DEFINITION_2,
}

GENERIC_BARCODED_SBS_LABWARE = BarcodedSbsLabware(
    uuid=GENERIC_UUID,
    barcode="AB9938",
示例#10
0
def test_LabwareDefinition__get_row_and_column_from_well_index__raises_error_if_row_count_not_set():
    labware_definition = LabwareDefinition(column_count=2)
    with pytest.raises(
        ValidationCollectionEmptyValueError, match="was empty row_count"
    ):
        labware_definition.get_row_and_column_from_well_index(0)
示例#11
0
def test_LabwareDefinition_autopopulate__fills_uuid():
    m = LabwareDefinition()
    m.autopopulate()
    assert m.uuid is not None
示例#12
0
    m = LabwareDefinition(row_count="bob", column_count=12)
    with pytest.raises(ValidationCollectionCannotCoerceError):
        m.validate_row_and_column_counts()


def test_LabwareDefinition_validate_row_and_column_counts__raises_error_if_column_invalid():
    m = LabwareDefinition(row_count=2, column_count="joe")
    with pytest.raises(ValidationCollectionCannotCoerceError):
        m.validate_row_and_column_counts()


@pytest.mark.parametrize(
    "labware_definition,test_row,test_column,expected_error,test_description",
    [
        (
            LabwareDefinition(row_count=2, column_count=2),
            1,
            2,
            PositionInvalidForLabwareDefinitionError,
            "column too high",
        ),
        (
            LabwareDefinition(row_count=2, column_count=2),
            2,
            1,
            PositionInvalidForLabwareDefinitionError,
            "row too high",
        ),
        (
            LabwareDefinition(row_count=2, column_count=2),
            1,
示例#13
0
    }
)
CLOUD_API_ENDPOINT = (
    f"api.{CLOUD_API_ENDPOINT_VALID_OPTIONS.get(CLOUD_API_ENDPOINT_USER_OPTION, 'curibio-test')}.com"
)

# Tanner (4/15/21): the latest HDF5 file version lives in mantarray-file-manager. This value represents the file version that is being created by the desktop app. When new mantarray-file-manager updates are brought into the desktop app, these values will differ indicating that FileWriterProcess needs to be updated to match the new file version
CURRENT_BETA1_HDF5_FILE_FORMAT_VERSION = "0.4.2"
CURRENT_BETA2_HDF5_FILE_FORMAT_VERSION = "1.0.1"


DEFAULT_SERVER_PORT_NUMBER = 4567

MAX_POSSIBLE_CONNECTED_BOARDS = 4

GENERIC_24_WELL_DEFINITION = LabwareDefinition(row_count=4, column_count=6)

FIRMWARE_VERSION_WIRE_OUT_ADDRESS = 0x21
BARCODE_SCANNER_TRIGGER_IN_ADDRESS = 0x41
BARCODE_SCANNER_TOP_WIRE_OUT_ADDRESS = 0x2A
BARCODE_SCANNER_MID_WIRE_OUT_ADDRESS = 0x2B
BARCODE_SCANNER_BOTTOM_WIRE_OUT_ADDRESS = 0x2C

CLEAR_BARCODE_TRIG_BIT = 0x5
START_BARCODE_SCAN_TRIG_BIT = 0x6

BARCODE_POLL_PERIOD = 15
BARCODE_CONFIRM_CLEAR_WAIT_SECONDS = 0.5
BARCODE_GET_SCAN_WAIT_SECONDS = 6

CLEARED_BARCODE_VALUE = chr(0) * 12
示例#14
0
from pulse3D.constants import XEM_SERIAL_NUMBER_UUID
from pulse3D.plate_recording import WellFile
import pytest
from stdlib_utils import drain_queue
from stdlib_utils import invoke_process_run_and_check_errors
from stdlib_utils import TestingQueue

from .fixtures import GENERIC_STORED_CUSTOMER_ID
from .fixtures import QUEUE_CHECK_TIMEOUT_SECONDS
from .fixtures_mc_simulator import get_null_subprotocol
from .fixtures_mc_simulator import get_random_subprotocol
from .helpers import confirm_queue_is_eventually_empty
from .helpers import confirm_queue_is_eventually_of_size
from .helpers import put_object_into_queue_and_raise_error_if_eventually_still_empty

WELL_DEF_24 = LabwareDefinition(row_count=4, column_count=6)

GENERIC_ADC_OFFSET_VALUES: Dict[int, Dict[str, int]] = dict()
for this_well_idx in range(24):
    GENERIC_ADC_OFFSET_VALUES[this_well_idx] = {
        "construct": this_well_idx * 2,
        "ref": this_well_idx * 2 + 1,
    }

GENERIC_WELL_MAGNETOMETER_CONFIGURATION = {
    channel_id: channel_id in (SERIAL_COMM_DEFAULT_DATA_CHANNEL,
                               SERIAL_COMM_SENSOR_AXIS_LOOKUP_TABLE["C"]["Z"])
    for channel_id in range(SERIAL_COMM_NUM_DATA_CHANNELS)
}
GENERIC_NUM_CHANNELS_ENABLED = sum(
    GENERIC_WELL_MAGNETOMETER_CONFIGURATION.values())
示例#15
0
def test_LabwareDefinition__hash__hashes_uuid():
    m = LabwareDefinition(uuid=GENERIC_UUID)
    assert hash(m) == hash((GENERIC_UUID,))
示例#16
0
def test_LabwareDefinition_super_is_called_during_init(mocker):
    spied_init = mocker.spy(DomainModel, "__init__")
    LabwareDefinition()
    assert spied_init.call_count == 1
示例#17
0
):
    domain_model_validate_internals_test(
        model,
        attribute_under_test,
        test_value,
        additional_kwargs,
        expected_error,
        expected_texts_in_error,
    )


@pytest.mark.parametrize(
    "model1,model2,expected,test_description",
    [
        (
            LabwareDefinition(row_count=8, column_count=12),
            LabwareDefinition(),
            False,
            "empty vs something",
        ),
        (
            LabwareDefinition(
                row_count=8, column_count=12, name="cool plate", uuid=GENERIC_UUID
            ),
            LabwareDefinition(
                row_count=8, column_count=12, name="cool plate", uuid=GENERIC_UUID
            ),
            True,
            "same everything",
        ),
        (LabwareDefinition(row_count=8, column_count=12), 9, False, "different types"),