From 15ee827efda0aed1330647267b02a10b81d64f54 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 25 Aug 2024 13:41:58 -0500 Subject: [PATCH] Hello world --- test/end2end/flash.py | 20 ++++++++++++++++++++ test/end2end/test.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 test/end2end/flash.py create mode 100644 test/end2end/test.py diff --git a/test/end2end/flash.py b/test/end2end/flash.py new file mode 100644 index 000000000..6c8b18acb --- /dev/null +++ b/test/end2end/flash.py @@ -0,0 +1,20 @@ +import usb.core +import subprocess + +def find_usb_device(vendor_id, product_id): + # Find USB devices + dev = usb.core.find(find_all=True) + # Loop through devices, printing vendor and product ids in decimal and hex + for cfg in dev: + if cfg.idVendor == vendor_id and cfg.idProduct == product_id: + return cfg + return None + +# Flash esp32 target +def flash_esp32(pio_env, port): + # Flash the ESP32 target + subprocess.run(["platformio", "run", "-e", pio_env, "-t", "upload", "-p", port]) + +def flash_nrf52(pio_env, port): + # Flash the nrf52 target + subprocess.run(["platformio", "run", "-e", pio_env, "-t", "upload", "-p", port]) \ No newline at end of file diff --git a/test/end2end/test.py b/test/end2end/test.py new file mode 100644 index 000000000..72a1f1326 --- /dev/null +++ b/test/end2end/test.py @@ -0,0 +1,36 @@ +import sys + +import pytest +import meshtastic +import meshtastic.serial_interface +from datetime import datetime +import flash + +heltec_v3 = ["COM17", "heltec-v3", "esp32"] +tbeam = ["COM18", "tbeam", "esp32"] +rak4631 = ["COM19", "rak4631", "nrf52"] + +@pytest.fixture(scope="module", params=[heltec_v3]) +def device(request): + port = request.param[0] + pio_env = request.param[1] + arch = request.param[2] + # Set up device + if arch == "esp32": + flash.flash_esp32(pio_env=pio_env, port=port) + elif arch == "nrf52": + flash.flash_nrf52(pio_env=pio_env, port=port) + # factory reset + yield meshtastic.serial_interface.SerialInterface(port) + # Tear down device + +# Test want_config responses from device +def test_get_info(device): + assert device is not None, "Expected port to be set" + assert len(device.nodes) > 0, "Expected at least one node in the device NodeDB" + assert device.localNode.localConfig is not None, "Expected LocalConfig to be set" + assert device.localNode.moduleConfig is not None, "Expected ModuleConfig to be set" + assert len(device.localNode.channels) > 0, "Expected at least one channel in the device" + +if __name__ == "__main__": + pytest.main() \ No newline at end of file