test: support v2 format for tree-id detection

In the function `treeid_from_manifest`, use dynamic format detection
instead of hard-coding the use of the version 1 format. Additionally,
directly access the `tree` pipeline and its `id` instead of going
via the `get_ids` helper function, which is only present in v1.py.
This commit is contained in:
Christian Kellner 2021-06-29 14:05:54 +02:00 committed by Achilleas Koutsou
parent 7576191c2d
commit 427266c583

View file

@ -12,7 +12,6 @@ import tempfile
import unittest
import osbuild.meta
from osbuild.formats import v1 as fmt
from osbuild.util import linux
@ -356,10 +355,17 @@ class OSBuild(contextlib.AbstractContextManager):
index = osbuild.meta.Index(os.curdir)
manifest_json = json.loads(manifest_data)
info = index.detect_format_info(manifest_json)
if not info:
raise RuntimeError("Unsupported manifest format")
fmt = info.module
manifest = fmt.load(manifest_json, index)
tree_id, _ = fmt.get_ids(manifest)
tree_id = manifest["tree"].id
return tree_id
@contextlib.contextmanager