From baf6fee98e0c7c6cf6cfd3fcf9e1429f70b58f5b Mon Sep 17 00:00:00 2001 From: "bodong.yang" Date: Fri, 14 Jun 2024 08:28:47 +0000 Subject: [PATCH] jetson-common: update to bspversion dump --- src/otaclient/app/boot_control/_jetson_common.py | 5 ++--- src/otaclient/app/boot_control/_jetson_uefi.py | 2 +- tests/test_otaclient/test_boot_control/test_jetson_cboot.py | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/otaclient/app/boot_control/_jetson_common.py b/src/otaclient/app/boot_control/_jetson_common.py index e44299905..dddd90def 100644 --- a/src/otaclient/app/boot_control/_jetson_common.py +++ b/src/otaclient/app/boot_control/_jetson_common.py @@ -73,10 +73,9 @@ def parse(cls, _in: str | BSPVersion | Any) -> Self: return cls(int(major_ver), int(major_rev), int(minor_rev)) raise ValueError(f"expect str or BSPVersion instance, get {type(_in)}") - @staticmethod - def dump(to_export: BSPVersion) -> str: + def dump(self) -> str: """Dump BSPVersion to string as "Rxx.yy.z".""" - return f"R{to_export.major_ver}.{to_export.major_rev}.{to_export.minor_rev}" + return f"R{self.major_ver}.{self.major_rev}.{self.minor_rev}" BSPVersionStr = Annotated[ diff --git a/src/otaclient/app/boot_control/_jetson_uefi.py b/src/otaclient/app/boot_control/_jetson_uefi.py index 7d41db999..81900ae2e 100644 --- a/src/otaclient/app/boot_control/_jetson_uefi.py +++ b/src/otaclient/app/boot_control/_jetson_uefi.py @@ -237,7 +237,7 @@ def write_firmware_update_hint_file( Schema: , """ - write_str_to_file_sync(hint_fpath, f"{slot_id},{BSPVersion.dump(bsp_version)}") + write_str_to_file_sync(hint_fpath, f"{slot_id},{bsp_version.dump()}") @staticmethod def parse_firmware_update_hint_file( diff --git a/tests/test_otaclient/test_boot_control/test_jetson_cboot.py b/tests/test_otaclient/test_boot_control/test_jetson_cboot.py index 937c6b677..6cc42894f 100644 --- a/tests/test_otaclient/test_boot_control/test_jetson_cboot.py +++ b/tests/test_otaclient/test_boot_control/test_jetson_cboot.py @@ -25,7 +25,6 @@ import pytest from otaclient.app.boot_control import _jetson_cboot -from otaclient.app.boot_control._jetson_cboot import _CBootControl from otaclient.app.boot_control._jetson_common import ( BSPVersion, FirmwareBSPVersion, @@ -70,7 +69,7 @@ def test_parse(self, _in: str, expected: BSPVersion): ), ) def test_dump(self, _in: BSPVersion, expected: str): - assert BSPVersion.dump(_in) == expected + assert _in.dump() == expected @pytest.mark.parametrize(