def test_post_serial_timeout_error(api_client, hardware, magdeck): async def thrower(*args, **kwargs): raise asyncio.TimeoutError() magdeck._bundled_fw = BundledFirmware("1234", Path("c:/aaa")) hardware.attached_modules = [magdeck] with patch("opentrons.hardware_control.modules.update_firmware") as p: p.side_effect = thrower resp = api_client.post('/modules/dummySerialMD/update') body = resp.json() assert resp.status_code == 500 assert body == {'message': 'Module not responding'}
def test_post_serial_update(api_client, hardware, tempdeck): async def update(*args, **kwargs): pass hardware.attached_modules = [tempdeck] tempdeck._bundled_fw = BundledFirmware("1234", Path("c:/aaa")) with patch("opentrons.hardware_control.modules.update_firmware") as p: p.side_effect = update resp = api_client.post('/modules/dummySerialTD/update') p.assert_called_once_with(tempdeck, tempdeck._bundled_fw.path, asyncio.get_event_loop()) body = resp.json() assert resp.status_code == 200 assert body == {'message': 'Successfully updated module dummySerialTD'}