def test_firmware_validation() -> None: downloader = FirmwareDownloader() installer = FirmwareInstaller() # Pixhawk1 and Pixhawk4 APJ firmwares should always work temporary_file = downloader.download(Vehicle.Sub, Platform.Pixhawk1) installer.validate_firmware(temporary_file, Platform.Pixhawk1) temporary_file = downloader.download(Vehicle.Sub, Platform.Pixhawk4) installer.validate_firmware(temporary_file, Platform.Pixhawk4) # New SITL firmwares should always work temporary_file = downloader.download(Vehicle.Sub, Platform.SITL, version="DEV") installer.validate_firmware(temporary_file, Platform.SITL) # Raise when validating Navigator firmwares (as test platform is x86) temporary_file = downloader.download(Vehicle.Sub, Platform.Navigator) with pytest.raises(InvalidFirmwareFile): installer.validate_firmware(temporary_file, Platform.Navigator) # Install SITL firmware temporary_file = downloader.download(Vehicle.Sub, Platform.SITL, version="DEV") board = FlightController(name="SITL", manufacturer="ArduPilot Team", platform=Platform.SITL) installer.install_firmware(temporary_file, board, pathlib.Path(f"{temporary_file}_dest"))
def test_firmware_validation() -> None: downloader = FirmwareDownloader() installer = FirmwareInstaller() # Pixhawk1 APJ firmwares should always work temporary_file = downloader.download(Vehicle.Sub, Platform.Pixhawk1) installer.validate_firmware(temporary_file, Platform.Pixhawk1) # New SITL firmwares should always work temporary_file = downloader.download(Vehicle.Sub, Platform.SITL, version="DEV") installer.validate_firmware(temporary_file, Platform.SITL) # Raise when validating for Undefined platform with pytest.raises(UndefinedPlatform): installer.validate_firmware(pathlib.Path(""), Platform.Undefined) # Raise when validating Navigator firmwares (as test platform is x86) temporary_file = downloader.download(Vehicle.Sub, Platform.NavigatorR5) with pytest.raises(InvalidFirmwareFile): installer.validate_firmware(temporary_file, Platform.NavigatorR5) # Install SITL firmware temporary_file = downloader.download(Vehicle.Sub, Platform.SITL, version="DEV") installer.install_firmware(temporary_file, Platform.SITL, pathlib.Path(f"{temporary_file}_dest"))
def validate_firmware(firmware_path: pathlib.Path, platform: Platform) -> None: FirmwareInstaller.validate_firmware(firmware_path, platform)