diff --git a/tests/unit_tests/test_download_types.py b/tests/unit_tests/test_download_types.py index 2ccf53f7e3..0d664b8db6 100644 --- a/tests/unit_tests/test_download_types.py +++ b/tests/unit_tests/test_download_types.py @@ -50,3 +50,37 @@ def test_recorded_firmware_path_yields_downloads(platform: str, tmp_path: Path) assert all( {"title", "description", "file", "download"} <= entry.keys() for entry in types ) + + +def _nrf52_files(tmp_path: Path, *built: str) -> list[str]: + """The files nrf52 offers for a build directory holding *built*.""" + (tmp_path / "zephyr").mkdir() + for name in built: + (tmp_path / name).touch() + storage = _wizard_storage() + storage.firmware_bin_path = tmp_path / "firmware.bin" + return [entry["file"] for entry in _download_types("nrf52", storage)] + + +@pytest.mark.parametrize( + ("built", "expected"), + [ + # Adafruit bootloader with the mcumgr OTA: MCUboot is chained behind it. + ( + ["zephyr/zephyr.uf2", "zephyr/app_update.bin"], + ["zephyr/zephyr.uf2", "firmware.zip", "zephyr/app_update.bin"], + ), + (["zephyr/zephyr.uf2"], ["zephyr/zephyr.uf2", "firmware.zip"]), + ( + ["zephyr/merged.hex", "zephyr/app_update.bin"], + ["zephyr/merged.hex", "zephyr/app_update.bin"], + ), + (["zephyr/merged.hex"], ["zephyr/merged.hex"]), + ([], ["zephyr/zephyr.hex"]), + ], +) +def test_nrf52_offers_the_mcumgr_image_whenever_it_was_built( + tmp_path: Path, built: list[str], expected: list[str] +) -> None: + """The mcumgr update image is offered beside a UF2 as well as beside a HEX.""" + assert _nrf52_files(tmp_path, *built) == expected