def test_ESPFirmwareFlasherWidget_update_firmware(esptool_is_installed, microbit): """ Ensure the widget for editing settings related to the ESP Firmware Flasher displays the referenced settings data in the expected way. """ editor = mock.MagicMock() view = mock.MagicMock() mm = ESPMode(editor, view) modes = mock.MagicMock() device_list = mu.logic.DeviceList(modes) device_list.add_device(microbit) espff = mu.interface.dialogs.ESPFirmwareFlasherWidget() espff.venv = mock.Mock() with mock.patch("os.path.exists", return_value=True): espff.setup(mm, device_list) espff.mode.repl = True espff.mode.plotter = True espff.mode.fs = True espff.device_type.setCurrentIndex(0) espff.update_firmware() espff.device_type.setCurrentIndex(1) espff.update_firmware()
def setup_modes(editor, view): """ Create a simple dictionary to hold instances of the available modes. *PREMATURE OPTIMIZATION ALERT* This may become more complex in future so splitting things out here to contain the mess. ;-) """ modes = { # "python": PythonMode(editor, view), # "circuitpython": CircuitPythonMode(editor, view), # "microbit": MicrobitMode(editor, view), "esp": ESPMode(editor, view), # "web": WebMode(editor, view), # "debugger": DebugMode(editor, view), } return modes
def test_ESPFirmwareFlasherWidget_update_firmware_no_deviec(): """ Ensure that we don't try to flash, when no device is connected. """ editor = mock.MagicMock() view = mock.MagicMock() mm = ESPMode(editor, view) modes = mock.MagicMock() device_list = mu.logic.DeviceList(modes) espff = mu.interface.dialogs.ESPFirmwareFlasherWidget() with mock.patch("os.path.exists", return_value=True): espff.setup(mm, device_list) espff.run_esptool = mock.MagicMock() espff.device_type.setCurrentIndex(0) espff.update_firmware() espff.run_esptool.assert_not_called()
def setup_modes(editor, view): """ Create a simple dictionary to hold instances of the available modes. *PREMATURE OPTIMIZATION ALERT* This may become more complex in future so splitting things out here to contain the mess. ;-) """ modes = { 'python': PythonMode(editor, view), 'adafruit': AdafruitMode(editor, view), 'microbit': MicrobitMode(editor, view), 'esp': ESPMode(editor, view), 'debugger': DebugMode(editor, view), } # Check if pgzero is available (without importing it) if any([m for m in pkgutil.iter_modules() if 'pgzero' in m]): modes['pygamezero'] = PyGameZeroMode(editor, view) # return available modes return modes
def setup_modes(editor, view): """ Create a simple dictionary to hold instances of the available modes. *PREMATURE OPTIMIZATION ALERT* This may become more complex in future so splitting things out here to contain the mess. ;-) """ modes = { "python": PythonMode(editor, view), "circuitpython": CircuitPythonMode(editor, view), "microbit": MicrobitMode(editor, view), "esp": ESPMode(editor, view), "web": WebMode(editor, view), "debugger": DebugMode(editor, view), } # Check if pgzero is available (without importing it) if any([m for m in pkgutil.iter_modules() if "pgzero" in m]): modes["pygamezero"] = PyGameZeroMode(editor, view) # return available modes return modes