def test_module_load_v2(module_model):
    mod = module_geometry.load_module(
        module_model, Location(Point(0, 0, 0), '3'))
    mod_def = module_geometry._load_module_definition(MAX_SUPPORTED_VERSION,
                                                      module_model)
    high_z = mod_def['dimensions']['bareOverallHeight']
    assert mod.highest_z == high_z
Example #2
0
def test_module_load_v1(v1_module_name):
    module_defs = json.loads(load_shared_data('module/definitions/1.json'))
    model = module_geometry.resolve_module_model(v1_module_name)
    mod = module_geometry.load_module(model, Location(Point(0, 0, 0), 'test'))
    mod_def = module_defs[v1_module_name]
    offset = Point(mod_def['labwareOffset']['x'],
                   mod_def['labwareOffset']['y'],
                   mod_def['labwareOffset']['z'])
    high_z = mod_def['dimensions']['bareOverallHeight']
    assert mod.highest_z == high_z
    assert mod.location.point == offset
    mod = module_geometry.load_module(model, Location(Point(1, 2, 3), 'test'))
    assert mod.highest_z == high_z + 3
    assert mod.location.point == (offset + Point(1, 2, 3))
    mod2 = module_geometry.load_module_from_definition(
        module_defs[v1_module_name], Location(Point(3, 2, 1), 'test2'))
    assert mod2.highest_z == high_z + 1
    assert mod2.location.point == (offset + Point(3, 2, 1))
def test_gen2_module_transforms():
    deck = Deck()
    tmod = module_geometry.load_module(
        module_geometry.TemperatureModuleModel.TEMPERATURE_V2,
        deck.position_for('1'), MAX_SUPPORTED_VERSION)
    assert tmod.labware_offset == Point(-1.45, -0.15, 80.09)
    tmod2 = module_geometry.load_module(
        module_geometry.TemperatureModuleModel.TEMPERATURE_V2,
        deck.position_for('3'), MAX_SUPPORTED_VERSION)
    assert tmod2.labware_offset == Point(1.15, -0.15, 80.09)

    mmod = module_geometry.load_module(
        module_geometry.MagneticModuleModel.MAGNETIC_V2,
        deck.position_for('1'), MAX_SUPPORTED_VERSION)
    assert mmod.labware_offset == Point(-1.175, -0.125, 82.25)
    mmod2 = module_geometry.load_module(
        module_geometry.MagneticModuleModel.MAGNETIC_V2,
        deck.position_for('3'), MAX_SUPPORTED_VERSION)
    assert mmod2.labware_offset == Point(1.425, -0.125, 82.25)
def test_highest_z():
    deck = Deck()
    assert deck.highest_z == 0
    lw = labware.load(labware_name, deck.position_for(1))
    deck[1] = lw
    assert deck.highest_z == pytest.approx(lw.wells()[0].top().point.z)
    del deck[1]
    assert deck.highest_z == 0
    mod = module_geometry.load_module(
        module_geometry.TemperatureModuleModel.TEMPERATURE_V1,
        deck.position_for(8))
    deck[8] = mod
    assert deck.highest_z == mod.highest_z
    lw = labware.load(labware_name, mod.location)
    mod.add_labware(lw)
    deck.recalculate_high_z()
    assert deck.highest_z == mod.highest_z
Example #5
0
def test_module_load_labware(module_name):
    labware_name = 'corning_96_wellplate_360ul_flat'
    labware_def = labware.get_labware_definition(labware_name)
    model = module_geometry.resolve_module_model(module_name)
    mod = module_geometry.load_module(model, Location(Point(0, 0, 0), 'test'))
    old_z = mod.highest_z
    lw = labware.load_from_definition(labware_def, mod.location)
    mod.add_labware(lw)
    assert mod.labware == lw
    assert mod.highest_z ==\
        (mod.location.point.z
         + labware_def['dimensions']['zDimension']
         + mod._over_labware)
    with pytest.raises(AssertionError):
        mod.add_labware(lw)
    mod.reset_labware()
    assert mod.labware is None
    assert mod.highest_z == old_z
def test_should_dodge():
    deck = Deck()
    # with no tc loaded, doesn't matter what the positions are
    assert not should_dodge_thermocycler(deck, deck.position_for(4),
                                         deck.position_for(9))
    deck[7] = module_geometry.load_module(
        module_geometry.ThermocyclerModuleModel.THERMOCYCLER_V1,
        deck.position_for(7))
    # with a tc loaded, some positions should require dodging
    assert should_dodge_thermocycler(deck, deck.position_for(12),
                                     deck.position_for(1))
    # but ones that weren't explicitly marked shouldn't
    assert not should_dodge_thermocycler(deck, deck.position_for(1),
                                         deck.position_for(2))
    # including a situation where we might have some messed up locations
    # with no parent
    assert not should_dodge_thermocycler(
        deck,
        deck.position_for(1)._replace(labware=None), deck.position_for(12))
def test_first_parent():
    deck = Deck()
    trough = labware.load(trough_name, deck.position_for(1))
    assert first_parent(trough) == '1'
    assert first_parent(trough['A2']) == '1'
    assert first_parent(None) is None
    assert first_parent('6') == '6'
    mod = module_geometry.load_module(
        module_geometry.TemperatureModuleModel.TEMPERATURE_V2,
        deck.position_for('6'), MAX_SUPPORTED_VERSION)
    mod_trough = mod.add_labware(labware.load(trough_name, mod.location))
    assert first_parent(mod_trough['A5']) == '6'
    assert first_parent(mod_trough) == '6'
    assert first_parent(mod) == '6'

    mod_trough._parent = mod_trough
    with pytest.raises(RuntimeError):
        # make sure we catch cycles
        first_parent(mod_trough)
def test_slot_collisions():
    d = Deck()
    mod_slot = '7'
    mod = module_geometry.load_module(
        module_geometry.ThermocyclerModuleModel.THERMOCYCLER_V1,
        d.position_for(mod_slot))
    d[mod_slot] = mod
    with pytest.raises(ValueError):
        d['7'] = 'not this time boyo'
    with pytest.raises(ValueError):
        d['8'] = 'nor this time boyo'
    with pytest.raises(ValueError):
        d['10'] = 'or even this time boyo'
    with pytest.raises(ValueError):
        d['11'] = 'def not this time though'

    lw_slot = '4'
    lw = labware.load(labware_name, d.position_for(lw_slot))
    d[lw_slot] = lw

    assert lw_slot in d
def test_slot_names():
    slots_by_int = list(range(1, 13))
    slots_by_str = [str(idx) for idx in slots_by_int]
    for method in (slots_by_int, slots_by_str):
        d = Deck()
        for idx, slot in enumerate(method):
            lw = labware.load(labware_name, d.position_for(slot))
            assert slot in d
            d[slot] = lw
            with pytest.raises(ValueError):
                d[slot] = 'not this time boyo'
            del d[slot]
            assert slot in d
            assert d[slot] is None
            mod = module_geometry.load_module(
                module_geometry.TemperatureModuleModel.TEMPERATURE_V1,
                d.position_for(slot))
            d[slot] = mod
            assert mod == d[slot]

    assert 'hasasdaia' not in d
    with pytest.raises(ValueError):
        d['ahgoasia'] = 'nope'