File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66
77class Cpe (NonEmptyString ):
8-
9- __MATCHER = re . compile ( '^cpe:/[aho]:[a-z\d._~-]+:[a-z\d._~-]+(?::[a-z\d._~-]+)?(?::[a-z\d._~-]+)?(?:$|\:[ a-z\d._~-]+)$' )
8+ __MATCHER = re . compile ( '^cpe:/[aho]:[a-z\d._~-]+:[a-z\d._~-]+(?::[a-z\d._~-]+)?(?::[a-z\d._~-]+)?(?:$|\:['
9+ ' a-z\d._~-]+)$' )
1010
1111 def __init__ (self , value : str ):
1212 super ().__init__ (value )
@@ -19,4 +19,3 @@ def _validate(self, value: str):
1919 raise ValueObjectError ('Value must be valid a CPE format strings.' )
2020 except ValueError :
2121 raise ValueObjectError ('Value must be valid a CPE format strings.' )
22-
Original file line number Diff line number Diff line change 55
66
77class TestCpeIdValueObject (unittest .TestCase ):
8+
9+ def __init__ (self , * args ):
10+ super ().__init__ (* args )
11+ self ._cls = Cpe
12+
13+ def test_vo_equal_hash (self ):
14+ original_vo_hash = hash (self ._cls ('cpe:/a:openjdk:openjdk:8u282' ))
15+ equal_vo_hash = hash (self ._cls ('cpe:/a:openjdk:openjdk:8u282' ))
16+ self .assertEqual (original_vo_hash , equal_vo_hash )
17+
18+ def test_vo_different_hash (self ):
19+ original_vo_hash = hash (self ._cls ('cpe:/a:openjdk:openjdk:8u282' ))
20+ not_equal_vo_hash = hash (self ._cls ('cpe:/o:microsoft:windows_10' ))
21+ self .assertNotEqual (original_vo_hash , not_equal_vo_hash )
22+
23+ def test_vo_equality (self ):
24+ original_vo = self ._cls ('cpe:/a:openjdk:openjdk:8u282' )
25+ equal_vo = self ._cls ('cpe:/a:openjdk:openjdk:8u282' )
26+ self .assertEqual (original_vo , equal_vo )
27+
28+ def test_vo_different_equality (self ):
29+ original_vo = self ._cls ('cpe:/a:openjdk:openjdk:8u282' )
30+ different_vo = self ._cls ('cpe:/o:microsoft:windows_10' )
31+ self .assertNotEqual (original_vo , different_vo )
32+
833 def test_value_return_input_value (self ):
934 vo = Cpe ('cpe:/a:openjdk:openjdk:8u282' )
1035 self .assertEqual ('cpe:/a:openjdk:openjdk:8u282' , vo .value ())
Original file line number Diff line number Diff line change 55
66
77class TestNullableCpeValueObject (unittest .TestCase ):
8+
9+ def __init__ (self , * args ):
10+ super ().__init__ (* args )
11+ self ._cls = NullableCpe
12+
13+ def test_vo_equal_hash (self ):
14+ original_vo_hash = hash (self ._cls ('cpe:/a:openjdk:openjdk:8u282' ))
15+ equal_vo_hash = hash (self ._cls ('cpe:/a:openjdk:openjdk:8u282' ))
16+ self .assertEqual (original_vo_hash , equal_vo_hash )
17+
18+ def test_vo_different_hash (self ):
19+ original_vo_hash = hash (self ._cls ('cpe:/a:openjdk:openjdk:8u282' ))
20+ not_equal_vo_hash = hash (self ._cls ('cpe:/o:microsoft:windows_10' ))
21+ self .assertNotEqual (original_vo_hash , not_equal_vo_hash )
22+
23+ def test_vo_equality (self ):
24+ original_vo = self ._cls ('cpe:/a:openjdk:openjdk:8u282' )
25+ equal_vo = self ._cls ('cpe:/a:openjdk:openjdk:8u282' )
26+ self .assertEqual (original_vo , equal_vo )
27+
28+ def test_vo_different_equality (self ):
29+ original_vo = self ._cls ('cpe:/a:openjdk:openjdk:8u282' )
30+ different_vo = self ._cls ('cpe:/o:microsoft:windows_10' )
31+ self .assertNotEqual (original_vo , different_vo )
832 def test_value_return_input_value (self ):
933 self .assertRaises (ValueObjectError , NullableCpe , '' )
1034
You can’t perform that action at this time.
0 commit comments