Skip to content

Commit

Permalink
external: update mock data in gen_depsolve_dnf4 to follow images
Browse files Browse the repository at this point in the history
This commit updates the generated mock meta-data from the
`gen_depsolve_dnf4` to follow the `gen_manifests` updates from the
images library, most notably:
osbuild/images#937
osbuild/images#943
  • Loading branch information
mvo5 committed Sep 25, 2024
1 parent bb5385e commit 24a4497
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
18 changes: 12 additions & 6 deletions src/otk_external_osbuild/command/gen_depsolve_dnf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,26 @@ def transform(packages):
return data


def mockdata(packages):
def mockdata(packages, architecture):
"""Mockdata as used by tests, we don't actually execute the depsolver
but return a map that's similar enough in format that the rest of the
compile can continue."""

# see https://github.com/osbuild/images/pull/937
def ver(pkg_name):
return str(ord(pkg_name[0]) % 9)

def release(pkg_name):
return str(ord(pkg_name[1]) % 9)
return [
{
"name": p,
"checksum": "sha256:" + hashlib.sha256(p.encode()).hexdigest(),
"remote_location": f"https://example.com/repo/packages/{p}",
"version": "0",
"epoch": "",
"release": "0",
"arch": "noarch",
"version": ver(p),
"epoch": "0",
"release": release(p) + ".fk1",
"arch": architecture,
}
for p in packages["include"] + [f"exclude:{p}" for p in packages["exclude"]]
]
Expand All @@ -42,7 +48,7 @@ def root(input_stream: TextIO) -> None:
data = json.loads(input_stream.read())
tree = data["tree"]
if "OTK_UNDER_TEST" in os.environ:
packages = mockdata(tree["packages"])
packages = mockdata(tree["packages"], tree["architecture"])
sys.stdout.write(json.dumps(transform(packages)))
return

Expand Down
16 changes: 8 additions & 8 deletions test/test_gen_depsolve_dnf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ def test_gen_depsolve_dnf4_under_test_mock_data(monkeypatch, capsys):
"checksum": "sha256:3d7b91c2dd3273400f26d21a492fcdfdc3dde228cd5627247dfef745ce717755",
"name": "pkg1",
"remote_location": "https://example.com/repo/packages/pkg1",
"version": "0",
"release": "0",
"arch": "noarch",
"epoch": "",
"version": "4",
"release": "8.fk1",
"arch": "x86_64",
"epoch": "0",
}, {
"arch": "noarch",
"arch": "x86_64",
"checksum": "sha256:93941c24b2276b2050d001b61bab64c58a8df5242bf491fa888f061cca12b51a",
"epoch": "",
"epoch": "0",
"name": "exclude:not-pkg2",
"release": "0",
"release": "3.fk1",
"remote_location": "https://example.com/repo/packages/exclude:not-pkg2",
"version": "0",
"version": "2",
},
],
},
Expand Down

0 comments on commit 24a4497

Please sign in to comment.