Skip to content

Commit e4f1b1e

Browse files
AequitoshUrist-McGit
authored andcommitted
test(download): use download schema through module
Instead of loading the download result schema as fixture, access it through the `schema` submodule of `debsbom` directly. This avoids any unexpected errors when running the tests in an environment where the directory structure may be slightly different, for example when building and testing the `debsbom` package using Debian's Python packaging tooling (pybuild specifically). Signed-off-by: Max R. Carrara <max@aequito.sh>
1 parent c8fecf2 commit e4f1b1e

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

tests/test_download.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
)
1616
from debsbom.download.download import DownloadResult, DownloadStatus
1717
from debsbom.resolver import PackageResolver, PackageStreamResolver
18+
from debsbom import schema
1819
from debsbom.dpkg.package import (
1920
BinaryPackage,
2021
SourcePackage,
@@ -265,14 +266,6 @@ def test_srcpkg_with_checksum(sdl):
265266
assert files[0].archive_name == "debian-ports"
266267

267268

268-
@pytest.fixture(scope="session")
269-
def dlschema():
270-
schemapath = Path(__file__).parent / "../src/debsbom/schema/schema-download.json"
271-
with open(schemapath) as f:
272-
schema = json.load(f)
273-
return schema
274-
275-
276269
@pytest.mark.parametrize(
277270
"dlresult",
278271
[
@@ -285,21 +278,21 @@ def dlschema():
285278
),
286279
],
287280
)
288-
def test_download_result_format(dlschema, dlresult):
281+
def test_download_result_format(dlresult):
289282
data = json.loads(dlresult.json())
290283
if data["status"] == DownloadStatus.OK:
291284
assert data["status"] == "ok"
292285

293-
jsonschema.validate(data, schema=dlschema)
286+
jsonschema.validate(data, schema=schema.download)
294287

295288

296-
def test_download_result_invalid(dlschema):
289+
def test_download_result_invalid():
297290
data = {
298291
"status": "unknown",
299292
"package": {"name": "foo", "version": "1.0"},
300293
}
301294
with pytest.raises(jsonschema.ValidationError):
302-
jsonschema.validate(data, schema=dlschema)
295+
jsonschema.validate(data, schema=schema.download)
303296

304297

305298
def test_local_file():

0 commit comments

Comments
 (0)