Skip to content

Commit 5fcb695

Browse files
[issue-426] update model: make created_using optional
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
1 parent 1dc829f commit 5fcb695

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/spdx_tools/spdx3/bump_from_spdx2/creation_info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def bump_creation_info(spdx2_creation_info: Spdx2_CreationInfo, payload: Payload
3636
spec_version=Version("3.0.0"),
3737
created=spdx2_creation_info.created,
3838
created_by=[],
39-
created_using=[],
4039
profile=[ProfileIdentifier.CORE, ProfileIdentifier.SOFTWARE, ProfileIdentifier.LICENSING],
4140
data_license="https://spdx.org/licenses/" + spdx2_creation_info.data_license,
4241
)

src/spdx_tools/spdx3/model/creation_info.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-FileCopyrightText: 2023 spdx contributors
22
#
33
# SPDX-License-Identifier: Apache-2.0
4+
from dataclasses import field
45
from datetime import datetime
56

67
from beartype.typing import List, Optional
@@ -16,19 +17,20 @@ class CreationInfo:
1617
spec_version: Version
1718
created: datetime
1819
created_by: List[str] # SPDXID of Agents
19-
created_using: List[str] # SPDXID of Tools
2020
profile: List[ProfileIdentifier]
21-
data_license: str
21+
data_license: Optional[str] = "CC0-1.0"
22+
created_using: List[str] = field(default_factory=list) # SPDXID of Tools
2223
comment: Optional[str] = None
2324

2425
def __init__(
2526
self,
2627
spec_version: Version,
2728
created: datetime,
2829
created_by: List[str],
29-
created_using: List[str],
3030
profile: List[ProfileIdentifier],
31-
data_license: str = "CC0",
31+
data_license: Optional[str] = "CC0-1.0",
32+
created_using: List[str] = None,
3233
comment: Optional[str] = None,
3334
):
35+
created_using = [] if created_using is None else created_using
3436
check_types_and_set_values(self, locals())

tests/spdx3/bump/test_actor_bump.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
def test_bump_actor(actor_type, actor_name, actor_mail, element_type, new_spdx_id):
3838
payload = Payload()
3939
document_namespace = "https://doc.namespace"
40-
creation_info = CreationInfo(Version("3.0.0"), datetime(2022, 1, 1), ["Creator"], [], [ProfileIdentifier.CORE])
40+
creation_info = CreationInfo(Version("3.0.0"), datetime(2022, 1, 1), ["Creator"], [ProfileIdentifier.CORE])
4141
actor = Actor(actor_type, actor_name, actor_mail)
4242

4343
agent_or_tool_id = bump_actor(actor, payload, document_namespace, creation_info)
@@ -54,8 +54,8 @@ def test_bump_actor(actor_type, actor_name, actor_mail, element_type, new_spdx_i
5454

5555

5656
def test_bump_actor_that_already_exists():
57-
creation_info_old = CreationInfo(Version("3.0.0"), datetime(2022, 1, 1), ["Creator"], [], [ProfileIdentifier.CORE])
58-
creation_info_new = CreationInfo(Version("3.0.0"), datetime(2023, 2, 2), ["Creator"], [], [ProfileIdentifier.CORE])
57+
creation_info_old = CreationInfo(Version("3.0.0"), datetime(2022, 1, 1), ["Creator"], [ProfileIdentifier.CORE])
58+
creation_info_new = CreationInfo(Version("3.0.0"), datetime(2023, 2, 2), ["Creator"], [ProfileIdentifier.CORE])
5959

6060
name = "some name"
6161
document_namespace = "https://doc.namespace"

tests/spdx3/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def creation_info_fixture(
101101
spec_version=spec_version,
102102
created=created,
103103
created_by=created_by,
104-
created_using=created_using,
105104
profile=profile,
106105
data_license=data_license,
106+
created_using=created_using,
107107
comment=comment,
108108
)
109109

tests/spdx3/model/test_creation_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_correct_initialization():
3232

3333
def test_invalid_initialization():
3434
with pytest.raises(TypeError) as err:
35-
CreationInfo("2.3", "2012-01-01", [], [], "core", 3, [])
35+
CreationInfo("2.3", "2012-01-01", [], "core", 3, [], [])
3636

3737
assert len(err.value.args[0]) == 5
3838
for error in err.value.args[0]:
@@ -44,6 +44,6 @@ def test_incomplete_initialization():
4444
CreationInfo("2.3")
4545

4646
assert (
47-
"__init__() missing 4 required positional arguments: 'created', 'created_by', 'created_using', and 'profile'"
47+
"__init__() missing 3 required positional arguments: 'created', 'created_by', and 'profile'"
4848
in err.value.args[0]
4949
)

0 commit comments

Comments
 (0)