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 2727
2828 # Initializes the CodeQL tools for scanning.
2929 - name : Initialize CodeQL
30- uses : github/codeql-action/init@v1
30+ uses : github/codeql-action/init@v2
3131 with :
3232 languages : ${{ matrix.language }}
3333 # If you wish to specify custom queries, you can do so here or in a config file.
3838 # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
3939 # If this step fails, then you should remove it and run the build manually (see below)
4040 - name : Autobuild
41- uses : github/codeql-action/autobuild@v1
41+ uses : github/codeql-action/autobuild@v2
4242
4343 # ℹ️ Command-line programs to run using the OS shell.
4444 # 📚 https://git.io/JvXDl
5252 # make release
5353
5454 - 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 2222Step .run = StepOverride .run
2323
2424from 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
2526from radish import errororacle
27+
2628errororacle .handle_exception = handle_exception_override
29+ apply_utctime_patch ()
2730##
2831#
2932
Original file line number Diff line number Diff line change 1- from unittest import TestCase
1+ from unittest import TestCase , mock
22from 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
44from tests .mocks import MockedStep , MockedTags
55
6-
76class TestBddTags (TestCase ):
87
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
1011 step = MockedStep ()
1112 look_for_bdd_tags (step )
1213 self .assertFalse (step .context .no_failure )
1314 self .assertIsNone (step .context .failure_class )
1415
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
1619 step = MockedStep ()
1720 step .all_tags = [MockedTags (name = 'warning' )]
1821 look_for_bdd_tags (step )
1922 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