16
16
#
17
17
# SPDX-License-Identifier: Apache-2.0
18
18
# Copyright (c) OWASP Foundation. All Rights Reserved.
19
+ from typing import List
19
20
from unittest import TestCase
20
21
from unittest .mock import Mock , patch
21
22
22
- from cyclonedx .model import ExternalReference , ExternalReferenceType
23
+ from cyclonedx .model import ExternalReference , ExternalReferenceType , Property
23
24
from cyclonedx .model .component import Component , ComponentType
24
25
25
26
@@ -115,7 +116,7 @@ def test_empty_basic_component_no_version(self) -> None:
115
116
self .assertEqual (len (c .hashes ), 0 )
116
117
self .assertEqual (len (c .get_vulnerabilities ()), 0 )
117
118
118
- def test_component_equal (self ) -> None :
119
+ def test_component_equal_1 (self ) -> None :
119
120
c = Component (
120
121
name = 'test-component' , version = '1.2.3'
121
122
)
@@ -135,3 +136,34 @@ def test_component_equal(self) -> None:
135
136
))
136
137
137
138
self .assertEqual (c , c2 )
139
+
140
+ def test_component_equal_2 (self ) -> None :
141
+ props : List [Property ] = [
142
+ Property (name = 'prop1' , value = 'val1' ),
143
+ Property (name = 'prop2' , value = 'val2' )
144
+ ]
145
+
146
+ c = Component (
147
+ name = 'test-component' , version = '1.2.3' , properties = props
148
+ )
149
+ c2 = Component (
150
+ name = 'test-component' , version = '1.2.3' , properties = props
151
+ )
152
+
153
+ self .assertEqual (c , c2 )
154
+
155
+ def test_component_equal_3 (self ) -> None :
156
+ c = Component (
157
+ name = 'test-component' , version = '1.2.3' , properties = [
158
+ Property (name = 'prop1' , value = 'val1' ),
159
+ Property (name = 'prop2' , value = 'val2' )
160
+ ]
161
+ )
162
+ c2 = Component (
163
+ name = 'test-component' , version = '1.2.3' , properties = [
164
+ Property (name = 'prop3' , value = 'val3' ),
165
+ Property (name = 'prop4' , value = 'val4' )
166
+ ]
167
+ )
168
+
169
+ self .assertNotEqual (c , c2 )
0 commit comments