Esempio n. 1
0
def test_get_circuitpython_version():
    """
    Given valid content of a boot_out.txt file on a connected device, return
    the version number of CircuitPython running on the board.
    """
    data = ("Adafruit CircuitPython 4.1.0 on 2019-08-02; "
            "Adafruit CircuitPlayground Express with samd21g18")
    mock_open = mock.mock_open(read_data=data)
    device_path = "device"
    with mock.patch("builtins.open", mock_open):
        assert circup.get_circuitpython_version(device_path) == "4.1.0"
        mock_open.assert_called_once_with(
            os.path.join(device_path, "boot_out.txt"))
Esempio n. 2
0
def test_get_circuitpython_version():
    """
    Given valid content of a boot_out.txt file on a connected device, return
    the version number of CircuitPython running on the board.
    """
    device_path = "device"
    data_no_id = (
        "Adafruit CircuitPython 4.1.0 on 2019-08-02; "
        "Adafruit CircuitPlayground Express with samd21g18"
    )
    with mock.patch("builtins.open", mock.mock_open(read_data=data_no_id)) as mock_open:
        assert circup.get_circuitpython_version(device_path) == ("4.1.0", "")
        mock_open.assert_called_once_with(os.path.join(device_path, "boot_out.txt"))
    data_with_id = data_no_id + "\r\n" "Board ID:this_is_a_board"
    with mock.patch(
        "builtins.open", mock.mock_open(read_data=data_with_id)
    ) as mock_open:
        assert circup.get_circuitpython_version(device_path) == (
            "4.1.0",
            "this_is_a_board",
        )
        mock_open.assert_called_once_with(os.path.join(device_path, "boot_out.txt"))