Skip to content

Commit 33278db

Browse files
[issue-432] use software fixtures in tests
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
1 parent 6acf1f0 commit 33278db

8 files changed

Lines changed: 44 additions & 251 deletions

File tree

tests/spdx3/fixtures.py

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
from spdx_tools.spdx3.model.licensing import (
3939
CustomLicense,
4040
CustomLicenseAddition,
41-
LicenseField,
4241
ListedLicense,
4342
ListedLicenseException,
4443
)
44+
from spdx_tools.spdx3.model.positive_integer_range import PositiveIntegerRange
4545
from spdx_tools.spdx3.model.security import (
4646
CvssV2VulnAssessmentRelationship,
4747
CvssV3VulnAssessmentRelationship,
@@ -164,6 +164,39 @@ def namespace_map_fixture(
164164
return NamespaceMap(prefix=prefix, namespace=namespace)
165165

166166

167+
def listed_license_fixture(
168+
license_id="https://spdx.test/tools-python/license_id",
169+
license_name="license name",
170+
license_text="license text",
171+
license_comment="license comment",
172+
see_also=None,
173+
is_osi_approved=True,
174+
is_fsf_libre=True,
175+
standard_license_header="license header",
176+
standard_license_template="license template",
177+
is_deprecated_license_id=True,
178+
obsoleted_by="https://spdx.test/tools-python/obsoleted_by_license_id",
179+
list_version_added="2.1",
180+
deprecated_version="2.2",
181+
):
182+
see_also = ["https://see.also/license"] if see_also is None else see_also
183+
return ListedLicense(
184+
license_id=license_id,
185+
license_name=license_name,
186+
license_text=license_text,
187+
license_comment=license_comment,
188+
see_also=see_also,
189+
is_osi_approved=is_osi_approved,
190+
is_fsf_libre=is_fsf_libre,
191+
standard_license_header=standard_license_header,
192+
standard_license_template=standard_license_template,
193+
is_deprecated_license_id=is_deprecated_license_id,
194+
obsoleted_by=obsoleted_by,
195+
list_version_added=list_version_added,
196+
deprecated_version=deprecated_version,
197+
)
198+
199+
167200
ELEMENT_DICT = {
168201
"spdx_id": "https://spdx.test/tools-python/element_fixture",
169202
"creation_info": creation_info_fixture(),
@@ -346,9 +379,9 @@ def namespace_map_fixture(
346379

347380
SOFTWARE_ARTIFACT_DICT = {
348381
"content_identifier": "https://spdx.test/tools-python/contentIdentifier",
349-
"purpose": SoftwarePurpose.OTHER,
350-
"concluded_license": LicenseField,
351-
"declared_license": LicenseField,
382+
"purpose": [SoftwarePurpose.OTHER],
383+
"concluded_license": listed_license_fixture(),
384+
"declared_license": listed_license_fixture(),
352385
"copyright_text": "copyrightText",
353386
"attribution_text": "attributionText",
354387
}
@@ -363,7 +396,7 @@ def namespace_map_fixture(
363396
"source_info": "sourceInfo",
364397
}
365398

366-
SNIPPET_DICT = {"byte_range": (1024, 2048), "line_range": (1, 4)}
399+
SNIPPET_DICT = {"byte_range": PositiveIntegerRange(1024, 2048), "line_range": PositiveIntegerRange(1, 4)}
367400

368401
SOFTWARE_DEPENDENCY_RELATIONSHIP_DICT = {
369402
"software_linkage": SoftwareDependencyLinkType.OTHER,
@@ -385,7 +418,6 @@ def namespace_map_fixture(
385418
"dataset_availability": DatasetAvailabilityType.QUERY,
386419
}
387420

388-
389421
FIXTURE_DICTS = {
390422
Agent: [ELEMENT_DICT],
391423
Person: [ELEMENT_DICT],

tests/spdx3/model/software/__init__.py

Whitespace-only changes.

tests/spdx3/model/software/test_file.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/spdx3/model/software/test_package.py

Lines changed: 0 additions & 70 deletions
This file was deleted.

tests/spdx3/model/software/test_sbom.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

tests/spdx3/model/software/test_snippet.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/spdx3/model/software/test_software_dependency_relationship.py

Lines changed: 0 additions & 59 deletions
This file was deleted.

tests/spdx3/model/test_element_and_licensing_subclasses.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
VexUnderInvestigationVulnAssessmentRelationship,
3434
Vulnerability,
3535
)
36+
from spdx_tools.spdx3.model.software import File, Package, Sbom, Snippet, SoftwareDependencyRelationship
3637
from tests.spdx3.fixtures import fixture_factory, get_fixture_dict
3738
from tests.spdx3.model.model_test_utils import InvalidTypeClass, get_property_names
3839

@@ -61,6 +62,11 @@
6162
VexNotAffectedVulnAssessmentRelationship,
6263
VexUnderInvestigationVulnAssessmentRelationship,
6364
Vulnerability,
65+
File,
66+
Package,
67+
Snippet,
68+
Sbom,
69+
SoftwareDependencyRelationship,
6470
]
6571

6672

0 commit comments

Comments
 (0)