Ejemplo n.º 1
0
def com_port():
    """Mock of a serial port."""
    port = ListPortInfo(DEFAULT_PORT)
    port.serial_number = "1234"
    port.manufacturer = "Virtual serial port"
    port.device = DEFAULT_PORT
    port.description = "Some serial port"

    return port
Ejemplo n.º 2
0
def get_mocked_com_port():
    """Mock of a serial port."""
    port = ListPortInfo("/dev/ttyUSB1234")
    port.device = "/dev/ttyUSB1234"
    port.serial_number = "1234567"
    port.manufacturer = "crownstone"
    port.description = "crownstone dongle - crownstone dongle"
    port.vid = 1234
    port.pid = 5678

    return port
Ejemplo n.º 3
0
def get_mocked_com_port_none_types():
    """Mock of a serial port with NoneTypes."""
    port = ListPortInfo("/dev/ttyUSB1234")
    port.device = "/dev/ttyUSB1234"
    port.serial_number = None
    port.manufacturer = None
    port.description = "crownstone dongle - crownstone dongle"
    port.vid = None
    port.pid = None

    return port
Ejemplo n.º 4
0
def fixture_patch_comports(mocker):
    comport = "COM1"

    dummy_port_info = ListPortInfo("")
    dummy_port_info.vid = STM_VID
    dummy_port_info.name = comport
    dummy_port_info.description = f"Device ({comport})"

    mocked_comports = mocker.patch.object(
        mc_comm.list_ports,
        "comports",
        autospec=True,
        return_value=[dummy_port_info],
    )
    yield comport, dummy_port_info.description, mocked_comports