-
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 instrument cache to hardware control
Closes #2236
- Loading branch information
Showing
5 changed files
with
56 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from opentrons import types | ||
from opentrons import hardware_control as hc | ||
|
||
|
||
async def test_cache_instruments(loop): | ||
dummy_instruments_attached = {types.Mount.LEFT: 'model_abc', | ||
types.Mount.RIGHT: None} | ||
hw_api = hc.API.build_hardware_simulator( | ||
attached_instruments=dummy_instruments_attached, loop=loop) | ||
await hw_api.cache_instrument_models() | ||
assert hw_api._attached_instruments == dummy_instruments_attached | ||
|
||
|
||
async def test_cache_instruments_hc(monkeypatch, hardware_controller_lockfile, | ||
running_on_pi, loop): | ||
if not hc.controller: | ||
pytest.skip('hardware controller not available (probably windows)') | ||
|
||
dummy_instruments_attached = {types.Mount.LEFT: 'model_abc', | ||
types.Mount.RIGHT: None} | ||
hw_api_cntrlr = hc.API.build_hardware_controller(loop=loop) | ||
|
||
def mock_driver_method(mount): | ||
attached_pipette = {'left': 'model_abc', 'right': None} | ||
return attached_pipette[mount] | ||
monkeypatch.setattr(hw_api_cntrlr._backend._smoothie_driver, | ||
'read_pipette_model', mock_driver_method) | ||
await hw_api_cntrlr.cache_instrument_models() | ||
assert hw_api_cntrlr._attached_instruments == dummy_instruments_attached |
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