-
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.
- Loading branch information
Showing
7 changed files
with
93 additions
and
36 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
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 |
---|---|---|
|
@@ -15,13 +15,15 @@ | |
TemperatureModuleModel, | ||
HeaterShakerModuleModel, | ||
ThermocyclerModuleModel, | ||
AbsorbanceReaderModel, | ||
ModuleType, | ||
) | ||
from opentrons.hardware_control.modules import ( | ||
TempDeck, | ||
MagDeck, | ||
Thermocycler, | ||
HeaterShaker, | ||
AbsorbanceReader, | ||
AbstractModule, | ||
SimulatingModule, | ||
build as build_module, | ||
|
@@ -44,6 +46,9 @@ async def test_get_modules_simulating() -> None: | |
"heatershaker": [ | ||
SimulatingModule(serial_number="444", model="heaterShakerModuleV1") | ||
], | ||
"absorbancereader": [ | ||
SimulatingModule(serial_number="555", model="absorbanceReaderV1") | ||
], | ||
} | ||
api = await hardware_control.API.build_hardware_simulator(attached_modules=mods) | ||
await asyncio.sleep(0.05) | ||
|
@@ -104,6 +109,7 @@ async def test_module_caching() -> None: | |
(TemperatureModuleModel.TEMPERATURE_V1, TempDeck), | ||
(ThermocyclerModuleModel.THERMOCYCLER_V1, Thermocycler), | ||
(HeaterShakerModuleModel.HEATER_SHAKER_V1, HeaterShaker), | ||
(AbsorbanceReaderModel.ABSORBANCE_READER_V1, AbsorbanceReader), | ||
], | ||
) | ||
async def test_create_simulating_module( | ||
|
@@ -232,13 +238,35 @@ async def mod_heatershaker() -> AsyncIterator[AbstractModule]: | |
await heatershaker.cleanup() | ||
|
||
|
||
@pytest.fixture | ||
async def mod_absorbancereader() -> AsyncIterator[AbstractModule]: | ||
usb_port = USBPort( | ||
name="", | ||
hub=False, | ||
port_number=0, | ||
device_path="/dev/ot_module_sim_absorbancereader0", | ||
) | ||
|
||
absorbancereader = await build_module( | ||
port="/dev/ot_module_sim_absorbancereader0", | ||
usb_port=usb_port, | ||
type=ModuleType.ABSORBANCE_READER, | ||
simulating=True, | ||
hw_control_loop=asyncio.get_running_loop(), | ||
execution_manager=ExecutionManager(), | ||
) | ||
yield absorbancereader | ||
await absorbancereader.cleanup() | ||
|
||
|
||
async def test_module_update_integration( | ||
monkeypatch: pytest.MonkeyPatch, | ||
mod_tempdeck: AbstractModule, | ||
mod_magdeck: AbstractModule, | ||
mod_thermocycler: AbstractModule, | ||
mod_heatershaker: AbstractModule, | ||
mod_thermocycler_gen2: AbstractModule, | ||
mod_absorbancereader: AbstractModule, | ||
) -> None: | ||
from opentrons.hardware_control import modules | ||
|
||
|
@@ -252,6 +280,7 @@ def async_return(result: T) -> "asyncio.Future[T]": | |
bootloader_kwargs = { | ||
"stdout": asyncio.subprocess.PIPE, | ||
"stderr": asyncio.subprocess.PIPE, | ||
"module": mod_tempdeck, | ||
} | ||
|
||
upload_via_avrdude_mock = mock.Mock( | ||
|
@@ -267,13 +296,15 @@ async def mock_find_avrdude_bootloader_port() -> str: | |
) | ||
|
||
# test temperature module update with avrdude bootloader | ||
bootloader_kwargs["module"] = mod_tempdeck | ||
await modules.update_firmware(mod_tempdeck, "fake_fw_file_path") | ||
upload_via_avrdude_mock.assert_called_once_with( | ||
"ot_module_avrdude_bootloader1", "fake_fw_file_path", bootloader_kwargs | ||
) | ||
upload_via_avrdude_mock.reset_mock() | ||
|
||
# test magnetic module update with avrdude bootloader | ||
bootloader_kwargs["module"] = mod_magdeck | ||
await modules.update_firmware(mod_magdeck, "fake_fw_file_path") | ||
upload_via_avrdude_mock.assert_called_once_with( | ||
"ot_module_avrdude_bootloader1", "fake_fw_file_path", bootloader_kwargs | ||
|
@@ -292,6 +323,7 @@ async def mock_find_bossa_bootloader_port() -> str: | |
modules.update, "find_bootloader_port", mock_find_bossa_bootloader_port | ||
) | ||
|
||
bootloader_kwargs["module"] = mod_thermocycler | ||
await modules.update_firmware(mod_thermocycler, "fake_fw_file_path") | ||
upload_via_bossa_mock.assert_called_once_with( | ||
"ot_module_bossa_bootloader1", "fake_fw_file_path", bootloader_kwargs | ||
|
@@ -310,25 +342,36 @@ async def mock_find_dfu_device_hs(pid: str, expected_device_count: int) -> str: | |
|
||
monkeypatch.setattr(modules.update, "find_dfu_device", mock_find_dfu_device_hs) | ||
|
||
bootloader_kwargs["module"] = mod_heatershaker | ||
await modules.update_firmware(mod_heatershaker, "fake_fw_file_path") | ||
upload_via_dfu_mock.assert_called_once_with( | ||
"df11", "fake_fw_file_path", bootloader_kwargs | ||
) | ||
upload_via_dfu_mock.reset_mock() | ||
|
||
# test thermocycler-gen2 module update with dfu bootloader | ||
async def mock_find_dfu_device_tc2(pid: str, expected_device_count: int) -> str: | ||
if expected_device_count == 3: | ||
return "df11" | ||
return "none" | ||
|
||
monkeypatch.setattr(modules.update, "find_dfu_device", mock_find_dfu_device_tc2) | ||
|
||
bootloader_kwargs["module"] = mod_thermocycler_gen2 | ||
await modules.update_firmware(mod_thermocycler_gen2, "fake_fw_file_path") | ||
upload_via_dfu_mock.assert_called_once_with( | ||
"df11", "fake_fw_file_path", bootloader_kwargs | ||
) | ||
|
||
mod_thermocycler_gen2 | ||
# Test absorbancereader update with byonoy library | ||
bootloader_kwargs["module"] = mod_absorbancereader | ||
byonoy_update_firmware_mock = mock.Mock(return_value=(async_return((True, "")))) | ||
mod_absorbancereader._driver.update_firmware = byonoy_update_firmware_mock # type: ignore | ||
|
||
assert not mod_absorbancereader.updating | ||
await modules.update_firmware(mod_absorbancereader, "fake_fw_file_path") | ||
byonoy_update_firmware_mock.assert_called_once_with("fake_fw_file_path") | ||
assert not mod_absorbancereader.updating | ||
|
||
|
||
async def test_get_bundled_fw(monkeypatch: pytest.MonkeyPatch, tmpdir: Path) -> None: | ||
|
@@ -346,6 +389,9 @@ async def test_get_bundled_fw(monkeypatch: pytest.MonkeyPatch, tmpdir: Path) -> | |
dummy_hs_file = Path(tmpdir) / "[email protected]" | ||
dummy_hs_file.write_text("hello") | ||
|
||
dummy_abs_file = Path(tmpdir) / "[email protected]" | ||
dummy_abs_file.write_text("hello") | ||
|
||
dummy_bogus_file = Path(tmpdir) / "[email protected]" | ||
dummy_bogus_file.write_text("hello") | ||
|
||
|
@@ -365,6 +411,9 @@ async def test_get_bundled_fw(monkeypatch: pytest.MonkeyPatch, tmpdir: Path) -> | |
"heatershaker": [ | ||
SimulatingModule(serial_number="444", model="heaterShakerModuleV1") | ||
], | ||
"absorbancereader": [ | ||
SimulatingModule(serial_number="555", model="absorbanceReaderV1") | ||
], | ||
} | ||
|
||
api = await API.build_hardware_simulator(attached_modules=mods) | ||
|
@@ -382,6 +431,9 @@ async def test_get_bundled_fw(monkeypatch: pytest.MonkeyPatch, tmpdir: Path) -> | |
assert api.attached_modules[3].bundled_fw == BundledFirmware( | ||
version="2.10.2", path=dummy_hs_file | ||
) | ||
assert api.attached_modules[4].bundled_fw == BundledFirmware( | ||
version="1.0.2", path=dummy_abs_file | ||
) | ||
for m in api.attached_modules: | ||
await m.cleanup() | ||
|
||
|