-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): Add labware load to protocol API
Closes #2240
- Loading branch information
Showing
6 changed files
with
149 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" Test the functions and classes in the protocol context """ | ||
|
||
from opentrons import protocol_api as papi | ||
|
||
import pytest | ||
|
||
|
||
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 = papi.Deck() | ||
for idx, slot in enumerate(method): | ||
assert slot in d | ||
d[slot] = 'its real' | ||
with pytest.raises(ValueError): | ||
d[slot] = 'not this time boyo' | ||
del d[slot] | ||
assert slot in d | ||
assert d[slot] is None | ||
|
||
assert 'hasasdaia' not in d | ||
with pytest.raises(ValueError): | ||
d['ahgoasia'] = 'nope' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import json | ||
import pkgutil | ||
from opentrons import protocol_api as papi, types | ||
|
||
# TODO: Remove this when labware load is actually wired up | ||
labware_name = 'generic_96_wellPlate_380_uL' | ||
labware_def = json.loads( | ||
pkgutil.get_data('opentrons', | ||
'shared_data/definitions2/{}.json'.format(labware_name))) | ||
|
||
|
||
def test_load_to_slot(monkeypatch): | ||
def dummy_load(labware): | ||
return labware_def | ||
monkeypatch.setattr(papi.labware, '_load_definition_by_name', dummy_load) | ||
ctx = papi.ProtocolContext() | ||
labware = ctx.load_labware_by_name(labware_name, '1') | ||
assert labware._offset == types.Point(0, 0, 0) | ||
other = ctx.load_labware_by_name(labware_name, 2) | ||
assert other._offset == types.Point(132.5, 0, 0) | ||
|
||
|
||
def test_loaded(monkeypatch): | ||
def dummy_load(labware): | ||
return labware_def | ||
monkeypatch.setattr(papi.labware, '_load_definition_by_name', dummy_load) | ||
ctx = papi.ProtocolContext() | ||
labware = ctx.load_labware_by_name(labware_name, '1') | ||
assert ctx.loaded_labwares[1] == labware | ||
|
||
|
||
def test_from_backcompat(monkeypatch): | ||
def dummy_load(labware): | ||
return labware_def | ||
monkeypatch.setattr(papi.labware, '_load_definition_by_name', dummy_load) | ||
ctx = papi.ProtocolContext() | ||
papi.back_compat.reset(ctx) | ||
lw = papi.back_compat.labware.load(labware_name, 3) | ||
assert lw == ctx.loaded_labwares[3] |