diff --git a/ntia_conformance_checker/sbom_checker.py b/ntia_conformance_checker/sbom_checker.py index 8d1bd80..f2892ee 100644 --- a/ntia_conformance_checker/sbom_checker.py +++ b/ntia_conformance_checker/sbom_checker.py @@ -74,18 +74,18 @@ def get_components_without_names(self): components_without_names.append(package.spdx_id) return components_without_names - def get_components_without_versions(self, returnTuples=False): + def get_components_without_versions(self, return_tuples=False): """Retrieve name and/or SPDX ID of components without versions.""" components_without_versions = [] for package in self.doc.packages: if not package.version: - if returnTuples: + if return_tuples: components_without_versions.append((package.name, package.spdx_id)) else: components_without_versions.append(package.name) return components_without_versions - def get_components_without_suppliers(self, returnTuples=False): + def get_components_without_suppliers(self, return_tuples=False): """Retrieve name and/or SPDX ID of components without suppliers.""" components_without_suppliers = [] for package in self.doc.packages: @@ -99,7 +99,7 @@ def get_components_without_suppliers(self, returnTuples=False): package.originator, SpdxNoAssertion ) if no_package_supplier and no_package_originator: - if returnTuples: + if return_tuples: components_without_suppliers.append((package.name, package.spdx_id)) else: components_without_suppliers.append(package.name) diff --git a/tests/test_checker.py b/tests/test_checker.py index 4776d92..f379b5f 100644 --- a/tests/test_checker.py +++ b/tests/test_checker.py @@ -9,12 +9,6 @@ import ntia_conformance_checker.sbom_checker as sbom_checker -import logging - -logging.basicConfig( - format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO) -logger = logging.getLogger(__name__) - dirname = os.path.join(os.path.dirname(__file__), "data", "no_elements_missing") test_files = [os.path.join(dirname, fn) for fn in os.listdir(dirname)] @@ -233,24 +227,29 @@ def test_sbomchecker_output_html(): assert got == expected + def test_components_without_functions(): - logger = logging.getLogger(__name__) - logger.info("In test") filepath = os.path.join( - os.path.dirname(__file__), "data", "other_tests", "test_components_without_functions.spdx" + os.path.dirname(__file__), + "data", + "other_tests", + "test_components_without_functions.spdx", ) sbom = sbom_checker.SbomChecker(filepath) components = sbom.get_components_without_names() assert components == ["SPDXRef-Package1"] components = sbom.get_components_without_versions() assert components == ["glibc-no-version-1", "glibc-no-version-2"] - components = sbom.get_components_without_versions(returnTuples=True) - assert components == [("glibc-no-version-1", "SPDXRef-Package2"), - ("glibc-no-version-2", "SPDXRef-Package3")] + components = sbom.get_components_without_versions(return_tuples=True) + assert components == [ + ("glibc-no-version-1", "SPDXRef-Package2"), + ("glibc-no-version-2", "SPDXRef-Package3"), + ] components = sbom.get_components_without_suppliers() assert components == ["glibc-no-supplier"] - components = sbom.get_components_without_suppliers(returnTuples=True) + components = sbom.get_components_without_suppliers(return_tuples=True) assert components == [("glibc-no-supplier", "SPDXRef-Package4")] - # TODO: Not sure how to test this. If any package misses the SPDXID the whole file seems to be invalid. - #components = sbom.get_components_without_identifiers() - #assert components == ["glibc-no-identifier"] + # Not sure how to test this. If any package misses the SPDXID the whole file seems to be + # invalid. + # components = sbom.get_components_without_identifiers() + # assert components == ["glibc-no-identifier"]