3333class TestVulnerabilityModel (TestCase ):
3434
3535 def test_generate_vulcoid_given_timestamp_object (self ):
36- timestamp_object = datetime (2021 , 1 , 1 , 11 , 12 , 13 )
37- expected_vulcoid = "VULCOID-2021-01-01111213 "
36+ timestamp_object = datetime (2021 , 1 , 1 , 11 , 12 , 13 , 2000 )
37+ expected_vulcoid = "VULCOID-20210101-1112-1300 "
3838 found_vulcoid = models .Vulnerability .generate_vulcoid (timestamp_object )
3939 assert expected_vulcoid == found_vulcoid
4040
4141 def test_generate_vulcoid (self ):
42- expected_vulcoid = "VULCOID-2021-01-01111213 "
43- with freeze_time ("2021-01-01 11:12:13" ):
42+ expected_vulcoid = "VULCOID-20210101-1112-1300 "
43+ with freeze_time ("2021-01-01 11:12:13.0000 " ):
4444 found_vulcoid = models .Vulnerability .generate_vulcoid ()
4545 assert expected_vulcoid == found_vulcoid
4646
@@ -52,22 +52,11 @@ def test_vulnerability_save_with_vulnerability_id(self):
5252 @pytest .mark .django_db
5353 def test_vulnerability_save_without_vulnerability_id (self ):
5454 assert models .Vulnerability .objects .filter (
55- vulnerability_id = "VULCOID-2021-01-01111213 "
55+ vulnerability_id = "VULCOID-20210101-1112-1300 "
5656 ).count () == 0
5757
58- with freeze_time ("2021-01-01 11:12:13" ):
58+ with freeze_time ("2021-01-01 11:12:13.0000 " ):
5959 models .Vulnerability (vulnerability_id = "" ).save ()
6060 assert models .Vulnerability .objects .filter (
61- vulnerability_id = "VULCOID-2021-01-01111213"
62- ).count () == 1
63-
64- assert models .Vulnerability .objects .filter (
65- vulnerability_id = "VULCOID-2021-01-01111214"
66- ).count () == 0
67-
68- with freeze_time ("2021-01-01 11:12:13" , tick = True ):
69- # This context manager sets time to "2021-01-01 11:12:13" and starts the clock.
70- models .Vulnerability (vulnerability_id = "" ).save ()
71- assert models .Vulnerability .objects .filter (
72- vulnerability_id = "VULCOID-2021-01-01111214"
61+ vulnerability_id = "VULCOID-20210101-1112-1300"
7362 ).count () == 1
0 commit comments