Skip to content

Commit

Permalink
fixup! tests
Browse files Browse the repository at this point in the history
  • Loading branch information
UpstreamData committed Sep 11, 2024
1 parent 1c0054c commit 4a48a30
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
15 changes: 9 additions & 6 deletions goosebit/updates/swdesc/rauc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ async def parse_file(file: Path):
def parse_descriptor(manifest: configparser.ConfigParser):
swdesc_attrs = {}
try:
# specified as optional in the RAUC docs
swdesc_attrs["version"] = semver.Version.parse(manifest["update"].get("version"))
swdesc_attrs["compatibility"] = [{"hw_model": "default", "hw_revision": manifest["update"]["compatible"]}]
except KeyError as e:
logger.warning(f"Parsing RAUC descriptor failed, error={e}")
raise ValueError("Parsing RAUC descriptor failed", e)
swdesc_attrs["version"] = semver.Version.parse(manifest["system"].get("version"))
swdesc_attrs["compatibility"] = [{"hw_model": "default", "hw_revision": manifest["system"]["compatible"]}]
except KeyError:
try:
swdesc_attrs["version"] = semver.Version.parse(manifest["update"].get("version"))
swdesc_attrs["compatibility"] = [{"hw_model": "default", "hw_revision": manifest["update"]["compatible"]}]
except KeyError as e:
logger.warning(f"Parsing RAUC descriptor failed, error={e}")
raise ValueError("Parsing RAUC descriptor failed", e)

return swdesc_attrs
Empty file added tests/updates/rauc/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Empty file added tests/updates/swu/__init__.py
Empty file.
Binary file added tests/updates/swu/software-header.raucb
Binary file not shown.
14 changes: 14 additions & 0 deletions tests/updates/swu/test_swdesc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from anyio import Path

from goosebit.updates.swdesc.rauc import parse_file


@pytest.mark.asyncio
async def test_parse_software_header():
resolved = await Path(__file__).resolve()
swdesc_attrs = await parse_file(resolved.parent / "software-header.raucb")
assert str(swdesc_attrs["version"]) == "8.8.1-11-g8c926e5+188370"
assert swdesc_attrs["compatibility"] == [
{"hw_model": "default", "hw_revision": "rauc-test-goosebit"},
]

0 comments on commit 4a48a30

Please sign in to comment.