From cdd061cf17d836e655c604c0181ff2eced328d0e Mon Sep 17 00:00:00 2001 From: OzTamari Date: Sun, 5 Dec 2021 10:53:46 +0200 Subject: [PATCH 01/15] Fixing 3 issues that hinder the tool: 1. yaml creation missing encoding. 2. NoAssert cannot be written to a file (not serializable) as it does not have default repr. 3. Problem creating relationships Signed-off-by: OzTamari --- spdx/relationship.py | 7 ++++++- spdx/utils.py | 2 +- spdx/writers/yaml.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spdx/relationship.py b/spdx/relationship.py index 980990ddc..dc17b34d7 100644 --- a/spdx/relationship.py +++ b/spdx/relationship.py @@ -82,6 +82,9 @@ def __init__(self, relationship=None, relationship_comment=None): self.relationship = relationship self.relationship_comment = relationship_comment + def __eq__(self, other): + return True if self.relationship == other.relationship else False + @property def has_comment(self): return self.relationship_comment is not None @@ -103,7 +106,7 @@ def validate(self, messages): Check that all the fields are valid. Appends any error messages to messages parameter shall be a ErrorMessages. """ - self.validate_relationship(messages) + return self.validate_relationship(messages) def validate_relationship(self, messages): r_type = self.relationship.split(" ")[1] @@ -112,3 +115,5 @@ def validate_relationship(self, messages): "Relationship type must be one of the constants defined in " "class spdx.relationship.Relationship" ) + + return messages diff --git a/spdx/utils.py b/spdx/utils.py index d40113ce2..7c0395a64 100644 --- a/spdx/utils.py +++ b/spdx/utils.py @@ -62,7 +62,7 @@ def datetime_from_iso_format(string): return None -class NoAssert(object): +class NoAssert(str): """ Represent SPDX NOASSERTION value. """ diff --git a/spdx/writers/yaml.py b/spdx/writers/yaml.py index 24600d8a7..2ccc6884d 100644 --- a/spdx/writers/yaml.py +++ b/spdx/writers/yaml.py @@ -27,4 +27,4 @@ def write_document(document, out, validate=True): writer = Writer(document) document_object = writer.create_document() - yaml.safe_dump(document_object, out, indent=2, explicit_start=True) + yaml.safe_dump(document_object, out, indent=2, explicit_start=True, encoding='utf-8') From fd0c33f509b5da4aeb9d4d67a1be53783a4184b3 Mon Sep 17 00:00:00 2001 From: OzTamari Date: Sun, 5 Dec 2021 11:49:44 +0200 Subject: [PATCH 02/15] Adjust fix in NoAsset to pass test Signed-off-by: OzTamari --- spdx/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spdx/utils.py b/spdx/utils.py index 7c0395a64..fc8b9d13e 100644 --- a/spdx/utils.py +++ b/spdx/utils.py @@ -62,7 +62,7 @@ def datetime_from_iso_format(string): return None -class NoAssert(str): +class NoAssert(object): """ Represent SPDX NOASSERTION value. """ @@ -73,6 +73,9 @@ def to_value(self): def __str__(self): return self.to_value() + def __repr__(self): + return self.to_value() + class UnKnown(object): """ @@ -91,6 +94,7 @@ def __repr__(self): def __eq__(self, other): return self.to_value() == other.to_value() + class SPDXNone(object): """ Represent SPDX None value. From 5772b0a0f57c6cf397ba99bd9500713679188280 Mon Sep 17 00:00:00 2001 From: OzTamari Date: Sun, 16 Jan 2022 11:52:08 +0200 Subject: [PATCH 03/15] Re-enabled relationships on non-TV output formats. Signed-off-by: OzTamari --- spdx/writers/rdf.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spdx/writers/rdf.py b/spdx/writers/rdf.py index 0ff7af211..5e1db3572 100644 --- a/spdx/writers/rdf.py +++ b/spdx/writers/rdf.py @@ -570,7 +570,7 @@ def relationships(self): """ Return a list of relationship nodes """ - return map(self.create_relationship_node, self.document.relationships) + return list(map(self.create_relationship_node, self.document.relationships)) class CreationInfoWriter(BaseWriter): @@ -1018,10 +1018,11 @@ def write(self, doc_node=None): for package_node in self.packages(): package_triple = (doc_node, self.spdx_namespace.describesPackage, package_node) self.graph.add(package_triple) - """# Add relationship - relate_node = self.relationships() - relate_triple = (doc_node, self.spdx_namespace.relationship, relate_node) - self.graph.add(relate_triple)""" + # Add relationship + for relate_node in self.relationships(): + relate_triple = (doc_node, self.spdx_namespace.relationship, relate_node) + self.graph.add(relate_triple) + # Add snippet snippet_nodes = self.snippets() for snippet in snippet_nodes: From 9b9711821703668853129452fd291def26200170 Mon Sep 17 00:00:00 2001 From: OzTamari Date: Sun, 5 Dec 2021 10:53:46 +0200 Subject: [PATCH 04/15] Fixing 3 issues that hinder the tool: 1. yaml creation missing encoding. 2. NoAssert cannot be written to a file (not serializable) as it does not have default repr. 3. Problem creating relationships Signed-off-by: OzTamari --- spdx/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spdx/utils.py b/spdx/utils.py index fc8b9d13e..765ac6234 100644 --- a/spdx/utils.py +++ b/spdx/utils.py @@ -62,7 +62,7 @@ def datetime_from_iso_format(string): return None -class NoAssert(object): +class NoAssert(str): """ Represent SPDX NOASSERTION value. """ From 54c0ec8c8c2d931754965787425c1a0bdb4a4bd2 Mon Sep 17 00:00:00 2001 From: OzTamari Date: Sun, 5 Dec 2021 11:49:44 +0200 Subject: [PATCH 05/15] Adjust fix in NoAsset to pass test Signed-off-by: OzTamari --- spdx/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spdx/utils.py b/spdx/utils.py index 765ac6234..fc8b9d13e 100644 --- a/spdx/utils.py +++ b/spdx/utils.py @@ -62,7 +62,7 @@ def datetime_from_iso_format(string): return None -class NoAssert(str): +class NoAssert(object): """ Represent SPDX NOASSERTION value. """ From 83862f972589e8ae58ddf424c3e0a4b841991ff8 Mon Sep 17 00:00:00 2001 From: NatalyaDalid Date: Sun, 20 Feb 2022 15:47:53 +0200 Subject: [PATCH 06/15] make SBOM aligned with SPDX Tool Validator --- setup.py | 4 ++-- spdx/writers/jsonyamlxml.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 9b9c7961d..297f158c1 100755 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ def test_suite(): long_description = fh.read() setup( - name='spdx-tools', - version='0.7.0a3', + name='ws-spdx-tools', + version='0.7.0a3.post3', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', diff --git a/spdx/writers/jsonyamlxml.py b/spdx/writers/jsonyamlxml.py index dec9beb68..f96520d0a 100644 --- a/spdx/writers/jsonyamlxml.py +++ b/spdx/writers/jsonyamlxml.py @@ -498,9 +498,14 @@ def create_document(self): document_describes = self.create_document_describes() self.document_object["documentDescribes"] = document_describes + unique_doc_packages = {} + for doc_package in self.document.packages: + if doc_package.spdx_id not in unique_doc_packages.keys(): + unique_doc_packages[doc_package.spdx_id] = doc_package + package_objects = [] file_objects = [] - for package in self.document.packages: + for package in unique_doc_packages.values(): package_info_object, files_in_package = self.create_package_info(package) package_objects.append(package_info_object) file_objects.extend(file for file in files_in_package if file not in file_objects) From 89e1abbf1ecf9669cd2d9ce99c8ff07c191a99eb Mon Sep 17 00:00:00 2001 From: NatalyaDalid Date: Mon, 21 Feb 2022 08:45:10 +0200 Subject: [PATCH 07/15] adding filter licenses and json converter --- spdx/writers/json.py | 16 +++++++++++++++- spdx/writers/jsonyamlxml.py | 11 +++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/spdx/writers/json.py b/spdx/writers/json.py index 0177cd104..c9e257d04 100644 --- a/spdx/writers/json.py +++ b/spdx/writers/json.py @@ -14,6 +14,20 @@ from spdx.writers.tagvalue import InvalidDocumentError from spdx.writers.jsonyamlxml import Writer from spdx.parsers.loggers import ErrorMessages +import numpy as np +import datetime + + +# this method has been added by the WhiteSouse PS Team. +def json_converter(obj): + if isinstance(obj, np.integer): + return int(obj) + elif isinstance(obj, np.floating): + return float(obj) + elif isinstance(obj, np.ndarray): + return obj.tolist() + elif isinstance(obj, datetime.datetime): + return obj.__str__() def write_document(document, out, validate=True): @@ -26,4 +40,4 @@ def write_document(document, out, validate=True): writer = Writer(document) document_object = writer.create_document() - json.dump(document_object, out, indent=4) + json.dump(document_object, out, indent=4, default=json_converter) diff --git a/spdx/writers/jsonyamlxml.py b/spdx/writers/jsonyamlxml.py index f96520d0a..f28012216 100644 --- a/spdx/writers/jsonyamlxml.py +++ b/spdx/writers/jsonyamlxml.py @@ -379,9 +379,16 @@ def __init__(self, document): def create_extracted_license(self): extracted_license_objects = [] - extracted_licenses = self.document.extracted_licenses + # commented by the WS PS Team + # extracted_licenses = self.document.extracted_licenses - for extracted_license in extracted_licenses: + # filter by unique identifier attribute in ExtractedLicense object, added by the WhiteSouse PS Team + unique_extracted_licenses = {} + for lic in self.document.extracted_licenses: + if lic.identifier not in unique_extracted_licenses.keys(): + unique_extracted_licenses[lic.identifier] = lic + + for extracted_license in unique_extracted_licenses.values(): extracted_license_object = dict() if isinstance(extracted_license.identifier, Literal): From 6b3a929be5d1f6f01e3de82a8b79d804ecbf51cf Mon Sep 17 00:00:00 2001 From: NatalyaDalid Date: Mon, 21 Feb 2022 08:47:54 +0200 Subject: [PATCH 08/15] update version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 297f158c1..bdcffb6b3 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def test_suite(): setup( name='ws-spdx-tools', - version='0.7.0a3.post3', + version='0.7.0a3.post4', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', From ba8f68c2f8970e4184141bb09f47620401ca52e7 Mon Sep 17 00:00:00 2001 From: rammatzkvosky <41573396+rammatzkvosky@users.noreply.github.com> Date: Sun, 27 Mar 2022 14:42:28 +0300 Subject: [PATCH 09/15] updating setup.py version to '0.7.0a3.post5' Signed-off-by: rammatzkvosky --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bdcffb6b3..ad8f0667d 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def test_suite(): setup( name='ws-spdx-tools', - version='0.7.0a3.post4', + version='0.7.0a3.post5', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', From 3ff52607ca5fd7d58071ac263584878a128f1aea Mon Sep 17 00:00:00 2001 From: rammatzkvosky Date: Thu, 31 Mar 2022 23:22:28 +0300 Subject: [PATCH 10/15] Adding condition to validate_checksum() for cases where check_sum.value is not available at WhiteSource Updating setup.py version to '0.7.0a3.post6' Signed-off-by: rammatzkvosky --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ad8f0667d..e6d0373d2 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def test_suite(): setup( name='ws-spdx-tools', - version='0.7.0a3.post5', + version='0.7.0a3.post6', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', From 8334dcbb506bea055eddf3695618ef459b7e533c Mon Sep 17 00:00:00 2001 From: DimarrWS <103509127+DimarrWS@users.noreply.github.com> Date: Tue, 28 Jun 2022 11:33:04 +0300 Subject: [PATCH 11/15] Added exception for delete check_sum --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e6d0373d2..85f3d61ad 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def test_suite(): setup( name='ws-spdx-tools', - version='0.7.0a3.post6', + version='0.7.0a4.post6', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', From 57a4672f6fb0016dea7088cccc1da8895c54e988 Mon Sep 17 00:00:00 2001 From: DimarrWS <103509127+DimarrWS@users.noreply.github.com> Date: Tue, 28 Jun 2022 11:40:44 +0300 Subject: [PATCH 12/15] Added exception for delete check_sum --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 85f3d61ad..02f92ae90 100755 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def test_suite(): setup( name='ws-spdx-tools', - version='0.7.0a4.post6', + version='0.7.0a3.post7', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', From 146bb65f21e73a430edc9985a5e4de5b24ec582c Mon Sep 17 00:00:00 2001 From: Nicolaus Weidner Date: Wed, 2 Nov 2022 22:03:33 +0100 Subject: [PATCH 13/15] Review comments for ws-patches PR Signed-off-by: Nicolaus Weidner --- setup.py | 4 ++-- spdx/relationship.py | 5 ++++- spdx/writers/json.py | 14 ++++---------- spdx/writers/jsonyamlxml.py | 5 ----- spdx/writers/rdf.py | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index 02f92ae90..9b9c7961d 100755 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ def test_suite(): long_description = fh.read() setup( - name='ws-spdx-tools', - version='0.7.0a3.post7', + name='spdx-tools', + version='0.7.0a3', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', diff --git a/spdx/relationship.py b/spdx/relationship.py index dc17b34d7..da302e07b 100644 --- a/spdx/relationship.py +++ b/spdx/relationship.py @@ -83,7 +83,10 @@ def __init__(self, relationship=None, relationship_comment=None): self.relationship_comment = relationship_comment def __eq__(self, other): - return True if self.relationship == other.relationship else False + return ( + isinstance(other, Relationship) + and self.relationship == other.relationship + ) @property def has_comment(self): diff --git a/spdx/writers/json.py b/spdx/writers/json.py index c9e257d04..a2b226fdf 100644 --- a/spdx/writers/json.py +++ b/spdx/writers/json.py @@ -14,20 +14,14 @@ from spdx.writers.tagvalue import InvalidDocumentError from spdx.writers.jsonyamlxml import Writer from spdx.parsers.loggers import ErrorMessages -import numpy as np import datetime -# this method has been added by the WhiteSouse PS Team. def json_converter(obj): - if isinstance(obj, np.integer): - return int(obj) - elif isinstance(obj, np.floating): - return float(obj) - elif isinstance(obj, np.ndarray): - return obj.tolist() - elif isinstance(obj, datetime.datetime): - return obj.__str__() + if isinstance(obj, datetime.datetime): + return str(obj) + else: + raise TypeError("No implementation available to serialize objects of type " + type(obj).__name__) def write_document(document, out, validate=True): diff --git a/spdx/writers/jsonyamlxml.py b/spdx/writers/jsonyamlxml.py index f28012216..e9516325a 100644 --- a/spdx/writers/jsonyamlxml.py +++ b/spdx/writers/jsonyamlxml.py @@ -379,10 +379,6 @@ def __init__(self, document): def create_extracted_license(self): extracted_license_objects = [] - # commented by the WS PS Team - # extracted_licenses = self.document.extracted_licenses - - # filter by unique identifier attribute in ExtractedLicense object, added by the WhiteSouse PS Team unique_extracted_licenses = {} for lic in self.document.extracted_licenses: if lic.identifier not in unique_extracted_licenses.keys(): @@ -545,4 +541,3 @@ def create_document(self): self.document_object["relationships"] = self.create_relationship_info() return self.document_object - diff --git a/spdx/writers/rdf.py b/spdx/writers/rdf.py index 5e1db3572..a7fc1a9c6 100644 --- a/spdx/writers/rdf.py +++ b/spdx/writers/rdf.py @@ -570,7 +570,7 @@ def relationships(self): """ Return a list of relationship nodes """ - return list(map(self.create_relationship_node, self.document.relationships)) + return map(self.create_relationship_node, self.document.relationships) class CreationInfoWriter(BaseWriter): From 293c811653db99abf171e7df714c5f7cfb34d48f Mon Sep 17 00:00:00 2001 From: Nicolaus Weidner Date: Thu, 3 Nov 2022 11:13:59 +0100 Subject: [PATCH 14/15] Fix broken tests and examples Signed-off-by: Nicolaus Weidner --- .../doc_write/json-simple-multi-package.json | 1 + tests/data/doc_write/json-simple-plus.json | 2 +- tests/data/doc_write/json-simple.json | 2 +- .../doc_write/xml-simple-multi-package.xml | 2 +- tests/data/doc_write/xml-simple-plus.xml | 78 +++++++++---------- tests/data/doc_write/xml-simple.xml | 2 +- .../doc_write/yaml-simple-multi-package.yaml | 2 +- tests/test_jsonyamlxml_parser.py | 9 ++- tests/utils_test.py | 2 +- 9 files changed, 49 insertions(+), 51 deletions(-) diff --git a/tests/data/doc_write/json-simple-multi-package.json b/tests/data/doc_write/json-simple-multi-package.json index 61e221c7e..d91d9ea54 100644 --- a/tests/data/doc_write/json-simple-multi-package.json +++ b/tests/data/doc_write/json-simple-multi-package.json @@ -76,3 +76,4 @@ } ] } + diff --git a/tests/data/doc_write/json-simple-plus.json b/tests/data/doc_write/json-simple-plus.json index a67c6e324..7a66e9bde 100644 --- a/tests/data/doc_write/json-simple-plus.json +++ b/tests/data/doc_write/json-simple-plus.json @@ -56,4 +56,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/tests/data/doc_write/json-simple.json b/tests/data/doc_write/json-simple.json index 187895621..9495f94c9 100644 --- a/tests/data/doc_write/json-simple.json +++ b/tests/data/doc_write/json-simple.json @@ -56,4 +56,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/tests/data/doc_write/xml-simple-multi-package.xml b/tests/data/doc_write/xml-simple-multi-package.xml index 4b7e6e85c..7552c6dcc 100644 --- a/tests/data/doc_write/xml-simple-multi-package.xml +++ b/tests/data/doc_write/xml-simple-multi-package.xml @@ -56,4 +56,4 @@ LGPL-2.1-or-later NOASSERTION - \ No newline at end of file + diff --git a/tests/data/doc_write/xml-simple-plus.xml b/tests/data/doc_write/xml-simple-plus.xml index f3b2bec73..5f48a1874 100644 --- a/tests/data/doc_write/xml-simple-plus.xml +++ b/tests/data/doc_write/xml-simple-plus.xml @@ -1,43 +1,37 @@ - - - SPDX-2.1 - CC0-1.0 - Sample_Document-V2.1 - SPDXRef-DOCUMENT - https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301 - SPDXRef-Package - - SPDXRef-Package - some/path - NOASSERTION - Some copyrught - - SOME code - - - SOME-SHA1 - SHA1 - - NOASSERTION - NOASSERTION - LGPL-2.1-or-later - - SPDXRef-File - - - - ./some/path/tofile - SPDXRef-File - - SOME-SHA1 - SHA1 - - NOASSERTION - NOASSERTION - LGPL-2.1-or-later - - - - - \ No newline at end of file + + SPDX-2.1 + CC0-1.0 + Sample_Document-V2.1 + SPDXRef-DOCUMENT + https://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301 + SPDXRef-Package + + SPDXRef-Package + some/path + NOASSERTION + Some copyrught + + SOME code + + + SOME-SHA1 + SHA1 + + NOASSERTION + NOASSERTION + LGPL-2.1-or-later + SPDXRef-File + + + ./some/path/tofile + SPDXRef-File + + SOME-SHA1 + SHA1 + + NOASSERTION + NOASSERTION + LGPL-2.1-or-later + + diff --git a/tests/data/doc_write/xml-simple.xml b/tests/data/doc_write/xml-simple.xml index 9eaca485b..0bf1e30c2 100644 --- a/tests/data/doc_write/xml-simple.xml +++ b/tests/data/doc_write/xml-simple.xml @@ -35,4 +35,4 @@ NOASSERTION LGPL-2.1-only - \ No newline at end of file + diff --git a/tests/data/doc_write/yaml-simple-multi-package.yaml b/tests/data/doc_write/yaml-simple-multi-package.yaml index a6d10db5c..e7ca1e40d 100644 --- a/tests/data/doc_write/yaml-simple-multi-package.yaml +++ b/tests/data/doc_write/yaml-simple-multi-package.yaml @@ -51,4 +51,4 @@ files: licenseConcluded: NOASSERTION licenseInfoInFiles: - LGPL-2.1-or-later - fileName: ./some/path/tofile \ No newline at end of file + fileName: ./some/path/tofile diff --git a/tests/test_jsonyamlxml_parser.py b/tests/test_jsonyamlxml_parser.py index 4198b8eff..82cb44b0d 100644 --- a/tests/test_jsonyamlxml_parser.py +++ b/tests/test_jsonyamlxml_parser.py @@ -1,4 +1,3 @@ - # Copyright (c) Xavier Figueroa # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -10,15 +9,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from collections import OrderedDict import io import json +import unittest +from collections import OrderedDict from unittest import TestCase from spdx.parsers import jsonparser, yamlparser, xmlparser from spdx.parsers.jsonyamlxmlbuilders import Builder from spdx.parsers.loggers import StandardLogger - from tests import utils_test from tests.utils_test import TestParserUtils @@ -54,6 +53,10 @@ def test_yaml_parser(self): expected_loc = utils_test.get_test_loc('doc_parse/expected.json') self.check_document(document, expected_loc) + @unittest.skip( + "This fails currently due to some differing whitespace. While trying to fix this in expected.json, " + "I realized that it is hopelessly out of date and should be replaced completely. " + "https://github.com/spdx/tools-python/issues/264") def test_xml_parser(self): parser = xmlparser.Parser(Builder(), StandardLogger()) test_file = utils_test.get_test_loc('formats/SPDXXmlExample.xml') diff --git a/tests/utils_test.py b/tests/utils_test.py index 3d2c9630a..7c33707d6 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -195,7 +195,7 @@ def check_json_scan(expected_file, result_file, regen=False): o.write(result) expected = load_and_clean_json(expected_file) - assert expected == result + assert result == expected def load_and_clean_yaml(location): From 93fe64dc3d4fdd18747e8c670d5e7ea61b34fc21 Mon Sep 17 00:00:00 2001 From: Nicolaus Weidner Date: Mon, 7 Nov 2022 13:55:43 +0100 Subject: [PATCH 15/15] Add DESCRIBES relationships to rdf test files Signed-off-by: Nicolaus Weidner --- tests/data/doc_write/rdf-simple-plus.json | 7 +++++-- tests/data/doc_write/rdf-simple.json | 7 +++++-- tests/utils_test.py | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/data/doc_write/rdf-simple-plus.json b/tests/data/doc_write/rdf-simple-plus.json index 5f84b380f..41866e956 100644 --- a/tests/data/doc_write/rdf-simple-plus.json +++ b/tests/data/doc_write/rdf-simple-plus.json @@ -61,8 +61,11 @@ "@rdf:resource": "http://spdx.org/licenses/LGPL-2.1-or-later" } } - }, + }, + "ns1:relationship": {"ns1:Relationship": {"@rdf:about": "SPDXRef-DOCUMENT", + "ns1:relatedSpdxElement": "SPDXRef-Package", + "ns1:relationshipType": "DESCRIBES"}}, "@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT" } } -} \ No newline at end of file +} diff --git a/tests/data/doc_write/rdf-simple.json b/tests/data/doc_write/rdf-simple.json index 7327c703f..ddb417538 100644 --- a/tests/data/doc_write/rdf-simple.json +++ b/tests/data/doc_write/rdf-simple.json @@ -61,8 +61,11 @@ }, "ns1:fileName": "./some/path/tofile" } - }, + }, + "ns1:relationship": {"ns1:Relationship": {"@rdf:about": "SPDXRef-DOCUMENT", + "ns1:relatedSpdxElement": "SPDXRef-Package", + "ns1:relationshipType": "DESCRIBES"}}, "@rdf:about": "http://www.spdx.org/tools#SPDXRef-DOCUMENT" } } -} \ No newline at end of file +} diff --git a/tests/utils_test.py b/tests/utils_test.py index 7c33707d6..c96debbe9 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -138,7 +138,7 @@ def check_rdf_scan(expected_file, result_file, regen=False): else: with io.open(expected_file, 'r', encoding='utf-8') as i: expected = sort_nested(json.load(i)) - assert expected == result + assert result == expected def load_and_clean_tv(location):