示例#1
0
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()
示例#2
0
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
示例#3
0
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()
示例#4
0
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
示例#5
0
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