Skip to content

Commit d46d731

Browse files
bactJPEWdev
authored andcommitted
Add hasInputs and hasOutputs check
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
1 parent 8acc493 commit d46d731

1 file changed

Lines changed: 40 additions & 27 deletions

File tree

tests/test_import.py

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# SPDX-FileType: SOURCE
22
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Class/individual/property/vocabulary entry existence tests are based on
5+
# the change log at:
6+
# https://github.com/spdx/spdx-3-model/blob/develop/CHANGELOG.md
37

48

59
def test_import():
@@ -20,12 +24,33 @@ def test_version():
2024
print(VERSION)
2125

2226

23-
def test_property_exist():
27+
def test_exist_class():
2428
"""
25-
Test the existence of specific properties in SPDX versions
29+
Test the existence of specific classes in SPDX versions
30+
"""
31+
from spdx_python_model import v3_0_1
32+
33+
# 3.0.1: "IndividualElement" class added
34+
e = v3_0_1.IndividualElement()
35+
2636

27-
Based on the change log:
28-
https://github.com/spdx/spdx-3-model/blob/develop/CHANGELOG.md
37+
def test_exist_individual():
38+
"""
39+
Test the existence of specific individuals in SPDX versions
40+
"""
41+
42+
from spdx_python_model import v3_0_1
43+
44+
# 3.0.1: "SpdxOrganization" individual added
45+
o = v3_0_1.Organization()
46+
assert (
47+
"SpdxOrganization" in o.NAMED_INDIVIDUALS
48+
), "3.0.1: 'SpdxOrganization' individual is missing"
49+
50+
51+
def test_exist_property():
52+
"""
53+
Test the existence of specific properties in SPDX versions
2954
"""
3055
from spdx_python_model import v3_0_1
3156

@@ -42,7 +67,7 @@ def test_property_exist():
4267
), "3.0.1: 'build_parameter' property is missing from 'build_Build'"
4368
assert not hasattr(
4469
b, "build_parameters"
45-
), "3.0.1: 'build_parameters' attribute should not be presented in 'build_Build'"
70+
), "3.0.1: 'build_parameters' property should not be presented in 'build_Build'"
4671

4772
# 3.0.1: "/Software/contentType" removed (duplicate of "/Core/contentType")
4873
f = v3_0_1.software_File()
@@ -51,20 +76,17 @@ def test_property_exist():
5176
), "3.0.1: 'contentType' property is missing from 'software_File'"
5277
assert not hasattr(
5378
f, "software_contentType"
54-
), "3.0.1: 'software_contentType' attribute should not be presented in 'software_File'"
79+
), "3.0.1: 'software_contentType' property should not be presented in 'software_File'"
5580

5681
p = v3_0_1.ai_AIPackage()
5782
assert hasattr(
5883
p, "ai_domain"
5984
), "3.0.1: 'ai_domain' property is missing from 'ai_AIPackage'"
6085

6186

62-
def test_vocab_entry_exist():
87+
def test_exist_vocab_entry():
6388
"""
6489
Test the existence of specific vocabulary entries in SPDX versions
65-
66-
Based on the change log:
67-
https://github.com/spdx/spdx-3-model/blob/develop/CHANGELOG.md
6890
"""
6991

7092
from spdx_python_model import v3_0_1
@@ -80,20 +102,11 @@ def test_vocab_entry_exist():
80102
assert not hasattr(
81103
r, "hasPrerequsite"
82104
), "3.0.1: 'hasPrerequsite' (misspelled) entry should not be presented in 'RelationshipType'"
83-
84-
85-
def test_special_individual_exist():
86-
"""
87-
Test the existence of specific individuals in SPDX versions
88-
89-
Based on the change log:
90-
https://github.com/spdx/spdx-3-model/blob/develop/CHANGELOG.md
91-
"""
92-
93-
from spdx_python_model import v3_0_1
94-
95-
# 3.0.1: "SpdxOrganization" added
96-
o = v3_0_1.Organization()
97-
assert (
98-
"SpdxOrganization" in o.NAMED_INDIVIDUALS
99-
), "3.0.1: 'SpdxOrganization' is missing"
105+
# 3.0.1: "hasInputs" replaced by "hasInput"
106+
assert not hasattr(
107+
r, "hasInputs"
108+
), "3.0.1: 'hasInputs' entry should not be presented in 'RelationshipType'"
109+
# 3.0.1: "hasOutputs" replaced by "hasOutput"
110+
assert not hasattr(
111+
r, "hasOutputs"
112+
), "3.0.1: 'hasOutputs' entry should not be presented in 'RelationshipType'"

0 commit comments

Comments
 (0)