Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
caila-marashaj committed Jan 9, 2025
1 parent 6b59349 commit 2d4bb28
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/docs/v2/deck_slots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For example, these two ``load_labware()`` commands are equivalent:

.. code-block:: python
protocol.load_labware("nest_96_wellplate_200ul_flat", "A1")
protocol.load_labware("nest_96_wellplate_200ul_flat", "A1", None)
.. versionadded:: 2.15

Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/engine/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ def load_labware(
],
label: Optional[str],
namespace: Optional[str],
version: Optional[int] = None,
schema: Optional[int] = 2,
version: Optional[int],
schema: Optional[int],
) -> LabwareCore:
"""Load a labware using its identifying parameters."""
load_location = self._convert_labware_location(location=location)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def load_labware(
],
label: Optional[str],
namespace: Optional[str],
version: Optional[int] = None,
schema: Optional[int] = 2,
version: Optional[int],
schema: Optional[int],
) -> LegacyLabwareCore:
"""Load a labware using its identifying parameters."""
if isinstance(location, OffDeckType):
Expand Down
4 changes: 2 additions & 2 deletions api/src/opentrons/protocol_api/core/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def load_labware(
],
label: Optional[str],
namespace: Optional[str],
version: Optional[int] = None,
schema: Optional[int] = 2,
version: Optional[int],
schema: Optional[int],
) -> LabwareCoreType:
"""Load a labware using its identifying parameters."""
...
Expand Down
2 changes: 2 additions & 0 deletions api/src/opentrons/protocol_api/module_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def load_labware(
version: Optional[int] = None,
adapter: Optional[str] = None,
lid: Optional[str] = None,
schema: Optional[int] = None,
) -> Labware:
"""Load a labware onto the module using its load parameters.
Expand Down Expand Up @@ -180,6 +181,7 @@ def load_labware(
namespace=namespace,
version=version,
location=load_location,
schema=schema,
)
if lid is not None:
if self._api_version < validation.LID_STACK_VERSION_GATE:
Expand Down
4 changes: 4 additions & 0 deletions api/src/opentrons/protocol_api/protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def load_labware(
version: Optional[int] = None,
adapter: Optional[str] = None,
lid: Optional[str] = None,
schema: Optional[int] = None,
) -> Labware:
"""Load a labware onto a location.
Expand Down Expand Up @@ -448,6 +449,8 @@ def load_labware(
values as the ``load_name`` parameter of :py:meth:`.load_lid_stack`. The
lid will use the same namespace as the labware, and the API will
choose the lid's version automatically.
:param schema: If specified, the schema version that will correspond to the
labware definition to load by default.
.. versionadded:: 2.15
"""
Expand Down Expand Up @@ -486,6 +489,7 @@ def load_labware(
label=label,
namespace=namespace,
version=version,
schema=schema,
)

if lid is not None:
Expand Down
22 changes: 22 additions & 0 deletions api/tests/opentrons/protocol_api/core/engine/test_protocol_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ def test_load_labware(
decoy: Decoy,
mock_engine_client: EngineClient,
subject: ProtocolCore,
api_version: APIVersion,
) -> None:
"""It should issue a LoadLabware command."""
decoy.when(
Expand All @@ -343,6 +344,8 @@ def test_load_labware(
"a_namespace",
456,
[EngineLabwareLoadParams("hello", "world", 654)],
api_version,
2,
)
).then_return(("some_namespace", 9001))

Expand Down Expand Up @@ -374,6 +377,7 @@ def test_load_labware(
label="some_display_name", # maps to optional display name
namespace="a_namespace",
version=456,
schema=2,
)

assert isinstance(result, LabwareCore)
Expand Down Expand Up @@ -405,6 +409,7 @@ def test_load_labware_on_staging_slot(
decoy: Decoy,
mock_engine_client: EngineClient,
subject: ProtocolCore,
api_version: APIVersion,
) -> None:
"""It should issue a LoadLabware command for a labware on a staging slot."""
decoy.when(
Expand All @@ -417,6 +422,8 @@ def test_load_labware_on_staging_slot(
"a_namespace",
456,
[EngineLabwareLoadParams("hello", "world", 654)],
api_version,
3,
)
).then_return(("some_namespace", 9001))

Expand Down Expand Up @@ -448,6 +455,7 @@ def test_load_labware_on_staging_slot(
label="some_display_name", # maps to optional display name
namespace="a_namespace",
version=456,
schema=3,
)

assert isinstance(result, LabwareCore)
Expand Down Expand Up @@ -479,6 +487,7 @@ def test_load_labware_on_labware(
decoy: Decoy,
mock_engine_client: EngineClient,
subject: ProtocolCore,
api_version: APIVersion,
) -> None:
"""It should issue a LoadLabware command onto an OnLabware location."""
mock_labware_core = decoy.mock(cls=LabwareCore)
Expand All @@ -494,6 +503,8 @@ def test_load_labware_on_labware(
"a_namespace",
456,
[EngineLabwareLoadParams("hello", "world", 654)],
api_version,
None,
)
).then_return(("some_namespace", 9001))

Expand Down Expand Up @@ -529,6 +540,7 @@ def test_load_labware_on_labware(
label="some_display_name",
namespace="a_namespace",
version=456,
schema=None,
)

assert isinstance(result, LabwareCore)
Expand All @@ -552,6 +564,7 @@ def test_load_labware_off_deck(
decoy: Decoy,
mock_engine_client: EngineClient,
subject: ProtocolCore,
api_version: APIVersion,
) -> None:
"""It should issue a LoadLabware off deck command."""
decoy.when(
Expand All @@ -564,6 +577,8 @@ def test_load_labware_off_deck(
"a_namespace",
456,
[EngineLabwareLoadParams("hello", "world", 654)],
api_version,
None,
)
).then_return(("some_namespace", 9001))

Expand Down Expand Up @@ -595,6 +610,7 @@ def test_load_labware_off_deck(
label="some_display_name", # maps to optional display name
namespace="a_namespace",
version=456,
schema=None,
)

assert isinstance(result, LabwareCore)
Expand Down Expand Up @@ -1189,6 +1205,8 @@ def test_load_labware_on_module(
"a_namespace",
456,
[EngineLabwareLoadParams("hello", "world", 654)],
api_version,
None,
)
).then_return(("some_namespace", 9001))

Expand Down Expand Up @@ -1227,6 +1245,7 @@ def test_load_labware_on_module(
label="some_display_name", # maps to optional display name
namespace="a_namespace",
version=456,
schema=None,
)

assert isinstance(result, LabwareCore)
Expand Down Expand Up @@ -1266,6 +1285,8 @@ def test_load_labware_on_non_connected_module(
"a_namespace",
456,
[EngineLabwareLoadParams("hello", "world", 654)],
api_version,
2,
)
).then_return(("some_namespace", 9001))

Expand Down Expand Up @@ -1303,6 +1324,7 @@ def test_load_labware_on_non_connected_module(
label="some_display_name", # maps to optional display name
namespace="a_namespace",
version=456,
schema=2,
)

assert isinstance(result, LabwareCore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def test_load_labware_off_deck_raises(
label="cool label",
namespace="cool namespace",
version=1337,
schema=None,
)


Expand All @@ -190,6 +191,7 @@ def test_load_labware_on_staging_slot_raises(
label="cool label",
namespace="cool namespace",
version=1337,
schema=None,
)


Expand Down Expand Up @@ -246,6 +248,7 @@ def test_load_labware(
label="cool label",
namespace="cool namespace",
version=1337,
schema=None,
)

assert isinstance(result, LegacyLabwareCore)
Expand Down Expand Up @@ -347,6 +350,7 @@ def test_load_labware_on_module(
label="cool label",
namespace="cool namespace",
version=1337,
schema=None,
)

assert isinstance(result, LegacyLabwareCore)
Expand Down Expand Up @@ -384,6 +388,7 @@ def test_load_labware_on_labware_raises(
label="cool label",
namespace="cool namespace",
version=1337,
schema=None,
)


Expand Down
3 changes: 3 additions & 0 deletions api/tests/opentrons/protocol_api/test_labware.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def test_load_labware(
namespace="a-namespace",
version=123,
location=mock_labware_core,
schema=None,
)
).then_return(new_mock_core)
decoy.when(new_mock_core.get_well_columns()).then_return([])
Expand All @@ -141,6 +142,7 @@ def test_load_labware(
label="a label",
namespace="a-namespace",
version=123,
schema=None,
)

assert isinstance(result, Labware)
Expand Down Expand Up @@ -175,6 +177,7 @@ def test_load_labware_from_definition(
version=1337,
label="a label",
location=mock_labware_core,
schema=None,
)
).then_return(new_mock_core)

Expand Down
3 changes: 3 additions & 0 deletions api/tests/opentrons/protocol_api/test_module_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def test_load_labware(
namespace="ideal",
version=101,
location=mock_core,
schema=None,
)
).then_return(mock_labware_core)

Expand Down Expand Up @@ -149,6 +150,7 @@ def test_load_labware_from_definition(
version=1337,
label="Some Display Name",
location=mock_core,
schema=None,
)
).then_return(mock_labware_core)

Expand Down Expand Up @@ -265,6 +267,7 @@ def test_load_labware_with_adapter(
namespace="ideal",
version=101,
location=mock_adapter_core,
schema=None,
)
).then_return(mock_labware_core)

Expand Down
7 changes: 7 additions & 0 deletions api/tests/opentrons/protocol_api/test_protocol_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def test_load_labware(
label="some_display_name",
namespace="some_namespace",
version=1337,
schema=2,
)
).then_return(mock_labware_core)

Expand All @@ -444,6 +445,7 @@ def test_load_labware(
label="some_display_name",
namespace="some_namespace",
version=1337,
schema=2,
)

assert isinstance(result, Labware)
Expand Down Expand Up @@ -472,6 +474,7 @@ def test_load_labware_off_deck(
label="some_display_name",
namespace="some_namespace",
version=1337,
schema=None,
)
).then_return(mock_labware_core)

Expand Down Expand Up @@ -533,6 +536,7 @@ def test_load_labware_on_staging_slot(
label="some_display_name",
namespace="some_namespace",
version=1337,
schema=None,
)
).then_return(mock_labware_core)

Expand Down Expand Up @@ -585,6 +589,7 @@ def test_load_labware_from_definition(
version=1337,
location=DeckSlotName.SLOT_1,
label="Some Display Name",
schema=None,
)
).then_return(mock_labware_core)

Expand Down Expand Up @@ -720,6 +725,7 @@ def test_load_labware_on_adapter(
label="some_display_name",
namespace="some_namespace",
version=1337,
schema=None,
)
).then_return(mock_labware_core)

Expand Down Expand Up @@ -773,6 +779,7 @@ def test_load_labware_with_lid(
label="some_display_name",
namespace="some_namespace",
version=1337,
schema=None,
)
).then_return(mock_labware_core)
decoy.when(mock_lid_core.get_well_columns()).then_return([])
Expand Down

0 comments on commit 2d4bb28

Please sign in to comment.