File tree Expand file tree Collapse file tree 4 files changed +26
-9
lines changed
tests/terraform_compliance/common Expand file tree Collapse file tree 4 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 27
27
28
28
# Initializes the CodeQL tools for scanning.
29
29
- name : Initialize CodeQL
30
- uses : github/codeql-action/init@v1
30
+ uses : github/codeql-action/init@v2
31
31
with :
32
32
languages : ${{ matrix.language }}
33
33
# If you wish to specify custom queries, you can do so here or in a config file.
38
38
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
39
39
# If this step fails, then you should remove it and run the build manually (see below)
40
40
- name : Autobuild
41
- uses : github/codeql-action/autobuild@v1
41
+ uses : github/codeql-action/autobuild@v2
42
42
43
43
# ℹ️ Command-line programs to run using the OS shell.
44
44
# 📚 https://git.io/JvXDl
52
52
# make release
53
53
54
54
- name : Perform CodeQL Analysis
55
- uses : github/codeql-action/analyze@v1
55
+ uses : github/codeql-action/analyze@v2
Original file line number Diff line number Diff line change
1
+ import radish .extensions .time_recorder
2
+ import datetime
3
+ import mock
4
+
5
+ def current_utc_time ():
6
+ return datetime .datetime .now (datetime .timezone .utc )
7
+
8
+ def apply_utctime_patch ():
9
+ # Patch datetime specifically within radish.extensions.time_recorder
10
+ radish .extensions .time_recorder .datetime = mock .Mock ()
11
+ radish .extensions .time_recorder .datetime .utcnow = current_utc_time
Original file line number Diff line number Diff line change 22
22
Step .run = StepOverride .run
23
23
24
24
from terraform_compliance .extensions .override_radish_hookerrors import handle_exception as handle_exception_override
25
+ from terraform_compliance .extensions .override_radish_utctime import apply_utctime_patch
25
26
from radish import errororacle
27
+
26
28
errororacle .handle_exception = handle_exception_override
29
+ apply_utctime_patch ()
27
30
##
28
31
#
29
32
Original file line number Diff line number Diff line change 1
- from unittest import TestCase
1
+ from unittest import TestCase , mock
2
2
from terraform_compliance .common .bdd_tags import look_for_bdd_tags
3
- from terraform_compliance .common . exceptions import Failure
3
+ from terraform_compliance .extensions . override_radish_utctime import current_utc_time
4
4
from tests .mocks import MockedStep , MockedTags
5
5
6
-
7
6
class TestBddTags (TestCase ):
8
7
9
- def test_unchanged_step_object (self ):
8
+ @mock .patch ('radish.extensions.time_recorder.datetime' )
9
+ def test_unchanged_step_object (self , mock_datetime ):
10
+ mock_datetime .utcnow .side_effect = current_utc_time # Patches within radish
10
11
step = MockedStep ()
11
12
look_for_bdd_tags (step )
12
13
self .assertFalse (step .context .no_failure )
13
14
self .assertIsNone (step .context .failure_class )
14
15
15
- def test_warning_case (self ):
16
+ @mock .patch ('radish.extensions.time_recorder.datetime' )
17
+ def test_warning_case (self , mock_datetime ):
18
+ mock_datetime .utcnow .side_effect = current_utc_time # Patches within radish
16
19
step = MockedStep ()
17
20
step .all_tags = [MockedTags (name = 'warning' )]
18
21
look_for_bdd_tags (step )
19
22
self .assertTrue (step .context .no_failure )
20
- self .assertEqual (step .context .failure_class , 'warning' )
23
+ self .assertEqual (step .context .failure_class , 'warning' )
You can’t perform that action at this time.
0 commit comments