Skip to content

Commit

Permalink
tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dholth committed Nov 15, 2021
1 parent a3b4276 commit 382483f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion spdx/parsers/jsonyamlxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ def unflatten_document(document):
if "files" in document:
for f in document.pop("files"):
f["name"] = f.pop("fileName")
# XXX must downstream rely on "sha1" property?
for checksum in f["checksums"]:
if checksum["algorithm"] == "SHA1":
f["sha1"] = checksum["checksumValue"]
Expand All @@ -1508,7 +1509,8 @@ def unflatten_document(document):
package["files"] = [{
"File": files_by_id[spdxid]} for spdxid in package["hasFiles"]
]
for checksum in package["checksums"]:
# XXX must downstream rely on "sha1" property?
for checksum in package.get("checksums", []):
if checksum["algorithm"] == "SHA1":
package["sha1"] = checksum["checksumValue"]
break
Expand Down
6 changes: 4 additions & 2 deletions tests/test_write_anything.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"SPDXRdfExample.rdf-yaml",
"SPDXRdfExample.rdf-xml",
"SPDXRdfExample.rdf-json",
"SPDXRdfExample.rdf-tag"
"SPDXRdfExample.rdf-tag",
"SPDXJsonExample2.2.json-rdf",
"SPDXJsonExample2.2.json-tag",
}

@pytest.mark.parametrize("out_format", ['rdf', 'yaml', 'xml', 'json', 'tag'])
Expand All @@ -56,7 +58,7 @@ def test_write_anything(in_file, out_format, tmpdir):
doc2, error2 = parse_anything.parse_file(out_fn)
result2 = utils_test.TestParserUtils.to_dict(doc2)
assert not error2

test = in_basename + "-" + out_format
if test not in UNSTABLE_CONVERSIONS:
assert result==result2
Expand Down

0 comments on commit 382483f

Please sign in to comment.