Skip to content

Commit 0103482

Browse files
committed
refactor!: rename spdx.is_compound_expression -> spdx.is_expression
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent a6998f9 commit 0103482

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

cyclonedx/factory/license.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from ..exception.factory import InvalidLicenseExpressionException, InvalidSpdxLicenseException
2121
from ..model.license import DisjunctiveLicense, LicenseExpression
22-
from ..spdx import fixup_id as spdx_fixup, is_compound_expression as is_spdx_compound_expression
22+
from ..spdx import fixup_id as spdx_fixup, is_expression as is_spdx_expression
2323

2424
if TYPE_CHECKING: # pragma: no cover
2525
from ..model import AttachedText, XsUri
@@ -57,11 +57,11 @@ def make_with_expression(self, expression: str, *,
5757
) -> LicenseExpression:
5858
"""Make a :class:`cyclonedx.model.license.LicenseExpression` with a compound expression.
5959
60-
Utilizes :func:`cyclonedx.spdx.is_compound_expression`.
60+
Utilizes :func:`cyclonedx.spdx.is_expression`.
6161
6262
:raises InvalidLicenseExpressionException: if param `value` is not known/supported license expression
6363
"""
64-
if is_spdx_compound_expression(expression):
64+
if is_spdx_expression(expression):
6565
return LicenseExpression(expression, acknowledgement=acknowledgement)
6666
raise InvalidLicenseExpressionException(expression)
6767

tests/test_factory_license.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_make_from_string_with_id(self) -> None:
3333
expected = DisjunctiveLicense(id='bar', text=text, url=url, acknowledgement=acknowledgement)
3434

3535
with unittest.mock.patch('cyclonedx.factory.license.spdx_fixup', return_value='bar'), \
36-
unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=True):
36+
unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=True):
3737
actual = LicenseFactory().make_from_string('foo',
3838
license_text=text,
3939
license_url=url,
@@ -48,7 +48,7 @@ def test_make_from_string_with_name(self) -> None:
4848
expected = DisjunctiveLicense(name='foo', text=text, url=url, acknowledgement=acknowledgement)
4949

5050
with unittest.mock.patch('cyclonedx.factory.license.spdx_fixup', return_value=None), \
51-
unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=False):
51+
unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=False):
5252
actual = LicenseFactory().make_from_string('foo',
5353
license_text=text,
5454
license_url=url,
@@ -61,7 +61,7 @@ def test_make_from_string_with_expression(self) -> None:
6161
expected = LicenseExpression('foo', acknowledgement=acknowledgement)
6262

6363
with unittest.mock.patch('cyclonedx.factory.license.spdx_fixup', return_value=None), \
64-
unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=True):
64+
unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=True):
6565
actual = LicenseFactory().make_from_string('foo',
6666
license_acknowledgement=acknowledgement)
6767

@@ -94,11 +94,11 @@ def test_make_with_name(self) -> None:
9494
def test_make_with_expression(self) -> None:
9595
acknowledgement = unittest.mock.NonCallableMock(spec=LicenseAcknowledgement)
9696
expected = LicenseExpression('foo', acknowledgement=acknowledgement)
97-
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=True):
97+
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=True):
9898
actual = LicenseFactory().make_with_expression(expression='foo', acknowledgement=acknowledgement)
9999
self.assertEqual(expected, actual)
100100

101101
def test_make_with_expression_raises(self) -> None:
102102
with self.assertRaises(InvalidLicenseExpressionException, msg='foo'):
103-
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_compound_expression', return_value=False):
103+
with unittest.mock.patch('cyclonedx.factory.license.is_spdx_expression', return_value=False):
104104
LicenseFactory().make_with_expression('foo')

tests/test_spdx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TestSpdxIsCompoundExpression(TestCase):
8282

8383
@idata(VALID_COMPOUND_EXPRESSIONS)
8484
def test_positive(self, valid_expression: str) -> None:
85-
actual = spdx.is_compound_expression(valid_expression)
85+
actual = spdx.is_expression(valid_expression)
8686
self.assertTrue(actual)
8787

8888
@data(
@@ -92,5 +92,5 @@ def test_positive(self, valid_expression: str) -> None:
9292
'Apache License, Version 2.0'
9393
)
9494
def test_negative(self, invalid_expression: str) -> None:
95-
actual = spdx.is_compound_expression(invalid_expression)
95+
actual = spdx.is_expression(invalid_expression)
9696
self.assertFalse(actual)

0 commit comments

Comments
 (0)