2121from cyclonedx .exception .factory import InvalidLicenseExpressionException , InvalidSpdxLicenseException
2222from cyclonedx .factory .license import LicenseFactory
2323from cyclonedx .model import AttachedText , XsUri
24- from cyclonedx .model .license import DisjunctiveLicense , LicenseExpression
24+ from cyclonedx .model .license import DisjunctiveLicense , LicenseAcknowledgement , LicenseExpression
2525
2626
2727class TestFactoryLicense (unittest .TestCase ):
2828
2929 def test_make_from_string_with_id (self ) -> None :
3030 text = unittest .mock .NonCallableMock (spec = AttachedText )
3131 url = unittest .mock .NonCallableMock (spec = XsUri )
32- expected = DisjunctiveLicense (id = 'bar' , text = text , url = url )
32+ acknowledgement = unittest .mock .NonCallableMock (spec = LicenseAcknowledgement )
33+ expected = DisjunctiveLicense (id = 'bar' , text = text , url = url , acknowledgement = acknowledgement )
3334
3435 with unittest .mock .patch ('cyclonedx.factory.license.spdx_fixup' , return_value = 'bar' ), \
3536 unittest .mock .patch ('cyclonedx.factory.license.is_spdx_compound_expression' , return_value = True ):
36- actual = LicenseFactory ().make_from_string ('foo' , license_text = text , license_url = url )
37+ actual = LicenseFactory ().make_from_string ('foo' ,
38+ license_text = text ,
39+ license_url = url ,
40+ license_acknowledgement = acknowledgement )
3741
3842 self .assertEqual (expected , actual )
3943
4044 def test_make_from_string_with_name (self ) -> None :
4145 text = unittest .mock .NonCallableMock (spec = AttachedText )
4246 url = unittest .mock .NonCallableMock (spec = XsUri )
43- expected = DisjunctiveLicense (name = 'foo' , text = text , url = url )
47+ acknowledgement = unittest .mock .NonCallableMock (spec = LicenseAcknowledgement )
48+ expected = DisjunctiveLicense (name = 'foo' , text = text , url = url , acknowledgement = acknowledgement )
4449
4550 with unittest .mock .patch ('cyclonedx.factory.license.spdx_fixup' , return_value = None ), \
4651 unittest .mock .patch ('cyclonedx.factory.license.is_spdx_compound_expression' , return_value = False ):
47- actual = LicenseFactory ().make_from_string ('foo' , license_text = text , license_url = url )
52+ actual = LicenseFactory ().make_from_string ('foo' ,
53+ license_text = text ,
54+ license_url = url ,
55+ license_acknowledgement = acknowledgement )
4856
4957 self .assertEqual (expected , actual )
5058
5159 def test_make_from_string_with_expression (self ) -> None :
52- expected = LicenseExpression ('foo' )
60+ acknowledgement = unittest .mock .NonCallableMock (spec = LicenseAcknowledgement )
61+ expected = LicenseExpression ('foo' , acknowledgement = acknowledgement )
5362
5463 with unittest .mock .patch ('cyclonedx.factory.license.spdx_fixup' , return_value = None ), \
5564 unittest .mock .patch ('cyclonedx.factory.license.is_spdx_compound_expression' , return_value = True ):
56- actual = LicenseFactory ().make_from_string ('foo' )
65+ actual = LicenseFactory ().make_from_string ('foo' ,
66+ license_acknowledgement = acknowledgement )
5767
5868 self .assertEqual (expected , actual )
5969
6070 def test_make_with_id (self ) -> None :
6171 text = unittest .mock .NonCallableMock (spec = AttachedText )
6272 url = unittest .mock .NonCallableMock (spec = XsUri )
63- expected = DisjunctiveLicense (id = 'bar' , text = text , url = url )
73+ acknowledgement = unittest .mock .NonCallableMock (spec = LicenseAcknowledgement )
74+ expected = DisjunctiveLicense (id = 'bar' , text = text , url = url , acknowledgement = acknowledgement )
6475
6576 with unittest .mock .patch ('cyclonedx.factory.license.spdx_fixup' , return_value = 'bar' ):
66- actual = LicenseFactory ().make_with_id (spdx_id = 'foo' , text = text , url = url )
77+ actual = LicenseFactory ().make_with_id (spdx_id = 'foo' , text = text , url = url , acknowledgement = acknowledgement )
6778
6879 self .assertEqual (expected , actual )
6980
@@ -75,14 +86,16 @@ def test_make_with_id_raises(self) -> None:
7586 def test_make_with_name (self ) -> None :
7687 text = unittest .mock .NonCallableMock (spec = AttachedText )
7788 url = unittest .mock .NonCallableMock (spec = XsUri )
78- expected = DisjunctiveLicense (name = 'foo' , text = text , url = url )
79- actual = LicenseFactory ().make_with_name (name = 'foo' , text = text , url = url )
89+ acknowledgement = unittest .mock .NonCallableMock (spec = LicenseAcknowledgement )
90+ expected = DisjunctiveLicense (name = 'foo' , text = text , url = url , acknowledgement = acknowledgement )
91+ actual = LicenseFactory ().make_with_name (name = 'foo' , text = text , url = url , acknowledgement = acknowledgement )
8092 self .assertEqual (expected , actual )
8193
8294 def test_make_with_expression (self ) -> None :
83- expected = LicenseExpression ('foo' )
95+ acknowledgement = unittest .mock .NonCallableMock (spec = LicenseAcknowledgement )
96+ expected = LicenseExpression ('foo' , acknowledgement = acknowledgement )
8497 with unittest .mock .patch ('cyclonedx.factory.license.is_spdx_compound_expression' , return_value = True ):
85- actual = LicenseFactory ().make_with_expression (expression = 'foo' )
98+ actual = LicenseFactory ().make_with_expression (expression = 'foo' , acknowledgement = acknowledgement )
8699 self .assertEqual (expected , actual )
87100
88101 def test_make_with_expression_raises (self ) -> None :
0 commit comments