|
1 | 1 | """Tests for the InstrumentContext public interface."""
|
2 | 2 | from collections import OrderedDict
|
3 | 3 | import inspect
|
4 |
| - |
5 | 4 | import pytest
|
6 | 5 | from pytest_lazyfixture import lazy_fixture # type: ignore[import-untyped]
|
7 | 6 | from decoy import Decoy
|
|
39 | 38 |
|
40 | 39 | from opentrons_shared_data.errors.exceptions import (
|
41 | 40 | CommandPreconditionViolated,
|
| 41 | + PipetteLiquidNotFoundError, |
42 | 42 | )
|
43 | 43 |
|
44 | 44 |
|
@@ -1268,3 +1268,53 @@ def test_aspirate_0_volume_means_aspirate_nothing(
|
1268 | 1268 | ),
|
1269 | 1269 | times=1,
|
1270 | 1270 | )
|
| 1271 | + |
| 1272 | + |
| 1273 | +@pytest.mark.parametrize("api_version", [APIVersion(2, 20)]) |
| 1274 | +def test_detect_liquid_presence( |
| 1275 | + decoy: Decoy, |
| 1276 | + mock_instrument_core: InstrumentCore, |
| 1277 | + subject: InstrumentContext, |
| 1278 | + mock_protocol_core: ProtocolCore, |
| 1279 | +) -> None: |
| 1280 | + """It should only return booleans. Not raise an exception.""" |
| 1281 | + mock_well = decoy.mock(cls=Well) |
| 1282 | + decoy.when( |
| 1283 | + mock_instrument_core.find_liquid_level(mock_well._core, False) |
| 1284 | + ).then_raise(PipetteLiquidNotFoundError()) |
| 1285 | + result = subject.detect_liquid_presence(mock_well) |
| 1286 | + assert isinstance(result, bool) |
| 1287 | + |
| 1288 | + |
| 1289 | +@pytest.mark.parametrize("api_version", [APIVersion(2, 20)]) |
| 1290 | +def test_require_liquid_presence( |
| 1291 | + decoy: Decoy, |
| 1292 | + mock_instrument_core: InstrumentCore, |
| 1293 | + subject: InstrumentContext, |
| 1294 | + mock_protocol_core: ProtocolCore, |
| 1295 | +) -> None: |
| 1296 | + """It should raise an exception when called.""" |
| 1297 | + mock_well = decoy.mock(cls=Well) |
| 1298 | + decoy.when(mock_instrument_core.find_liquid_level(mock_well._core, True)) |
| 1299 | + subject.require_liquid_presence(mock_well) |
| 1300 | + decoy.when( |
| 1301 | + mock_instrument_core.find_liquid_level(mock_well._core, True) |
| 1302 | + ).then_raise(PipetteLiquidNotFoundError()) |
| 1303 | + with pytest.raises(PipetteLiquidNotFoundError): |
| 1304 | + subject.require_liquid_presence(mock_well) |
| 1305 | + |
| 1306 | + |
| 1307 | +@pytest.mark.parametrize("api_version", [APIVersion(2, 20)]) |
| 1308 | +def test_measure_liquid_height( |
| 1309 | + decoy: Decoy, |
| 1310 | + mock_instrument_core: InstrumentCore, |
| 1311 | + subject: InstrumentContext, |
| 1312 | + mock_protocol_core: ProtocolCore, |
| 1313 | +) -> None: |
| 1314 | + """It should raise an exception when called.""" |
| 1315 | + mock_well = decoy.mock(cls=Well) |
| 1316 | + decoy.when( |
| 1317 | + mock_instrument_core.find_liquid_level(mock_well._core, False) |
| 1318 | + ).then_raise(PipetteLiquidNotFoundError()) |
| 1319 | + with pytest.raises(PipetteLiquidNotFoundError): |
| 1320 | + subject.measure_liquid_height(mock_well) |
0 commit comments