From 35a7f23b32e0aef87bfcb851fd9ed56b38833ed9 Mon Sep 17 00:00:00 2001 From: tdruez Date: Tue, 23 Jan 2024 15:14:13 -0700 Subject: [PATCH] Fix the test_scanpipe_cyclonedx_resolve_license test #807 Signed-off-by: tdruez --- scanpipe/tests/pipes/test_cyclonedx.py | 29 +++++++++++--------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/scanpipe/tests/pipes/test_cyclonedx.py b/scanpipe/tests/pipes/test_cyclonedx.py index 38362e09d..d6fae6e90 100644 --- a/scanpipe/tests/pipes/test_cyclonedx.py +++ b/scanpipe/tests/pipes/test_cyclonedx.py @@ -28,14 +28,11 @@ from hoppr_cyclonedx_models.cyclonedx_1_4 import ( CyclonedxSoftwareBillOfMaterialsStandard as Bom_1_4, ) +from hoppr_cyclonedx_models.cyclonedx_1_4 import License +from hoppr_cyclonedx_models.cyclonedx_1_4 import LicenseChoice from scanpipe.pipes import cyclonedx -# from hoppr_cyclonedx_models.cyclonedx_1_4 import License1 -# from hoppr_cyclonedx_models.cyclonedx_1_4 import LicenseChoice -# from hoppr_cyclonedx_models.cyclonedx_1_4 import License -# from hoppr_cyclonedx_models.cyclonedx_1_4 import LicenseChoice1 - class ScanPipeCycloneDXPipesTest(TestCase): bom_file = Path(__file__).parent.parent / "data/cyclonedx/nested.cdx.json" @@ -149,18 +146,16 @@ def test_scanpipe_cyclonedx_recursive_component_collector(self): self.assertEqual(result, expected) - # def test_scanpipe_cyclonedx_resolve_license(self): - # hopper_cdx_licensechoice_id = LicenseChoice( - # __root__=LicenseChoice1(license=License1(__root__=License(id="OFL-1.1"))) - # ) - # license_choice_dict = json.loads( - # hopper_cdx_licensechoice_id.json(exclude_unset=True, by_alias=True) - # ) - # - # result = cyclonedx.resolve_license(license_choice_dict) - # expected = "OFL-1.1" - # - # self.assertEqual(result, expected) + def test_scanpipe_cyclonedx_resolve_license(self): + hopper_cdx_licensechoice_id = LicenseChoice(license=License(id="OFL-1.1")) + license_choice_dict = json.loads( + hopper_cdx_licensechoice_id.json(exclude_unset=True, by_alias=True) + ) + + result = cyclonedx.resolve_license(license_choice_dict) + expected = "OFL-1.1" + + self.assertEqual(result, expected) def test_scanpipe_cyclonedx_get_declared_licenses(self): component = self.bom.components[0]