Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
graft src

global-exclude *.py[co] __pycache__ *.*~ .pytest-cache
16 changes: 16 additions & 0 deletions src/debsbom/schema/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 5 additions & 12 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
[
Expand All @@ -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():
Expand Down