diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..2debc0aa --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +graft src + +global-exclude *.py[co] __pycache__ *.*~ .pytest-cache diff --git a/src/debsbom/schema/__init__.py b/src/debsbom/schema/__init__.py new file mode 100644 index 00000000..f28b685d --- /dev/null +++ b/src/debsbom/schema/__init__.py @@ -0,0 +1,16 @@ +# Copyright (C) 2025 Siemens +# +# SPDX-License-Identifier: MIT + +import json +from pathlib import Path + +__all__ = [ + "download", +] + + +__DOWNLOAD_SCHEMA_PATH = Path(__file__).parent / "schema-download.json" + +with open(__DOWNLOAD_SCHEMA_PATH) as f: + download = json.load(f) diff --git a/tests/test_download.py b/tests/test_download.py index ed0bc58b..05a98ac8 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -15,6 +15,7 @@ ) from debsbom.download.download import DownloadResult, DownloadStatus from debsbom.resolver import PackageResolver, PackageStreamResolver +from debsbom import schema from debsbom.dpkg.package import ( BinaryPackage, SourcePackage, @@ -265,14 +266,6 @@ def test_srcpkg_with_checksum(sdl): assert files[0].archive_name == "debian-ports" -@pytest.fixture(scope="session") -def dlschema(): - schemapath = Path(__file__).parent / "../src/debsbom/schema/schema-download.json" - with open(schemapath) as f: - schema = json.load(f) - return schema - - @pytest.mark.parametrize( "dlresult", [ @@ -285,21 +278,21 @@ def dlschema(): ), ], ) -def test_download_result_format(dlschema, dlresult): +def test_download_result_format(dlresult): data = json.loads(dlresult.json()) if data["status"] == DownloadStatus.OK: assert data["status"] == "ok" - jsonschema.validate(data, schema=dlschema) + jsonschema.validate(data, schema=schema.download) -def test_download_result_invalid(dlschema): +def test_download_result_invalid(): data = { "status": "unknown", "package": {"name": "foo", "version": "1.0"}, } with pytest.raises(jsonschema.ValidationError): - jsonschema.validate(data, schema=dlschema) + jsonschema.validate(data, schema=schema.download) def test_local_file():