Skip to content

Commit

Permalink
test xtriggers satisfied
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Oct 26, 2023
1 parent f8e0685 commit f926e1d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/integration/test_xtrigger_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""


async def test_2_xtriggers(flow, start, scheduler):
async def test_2_xtriggers(flow, start, scheduler, monkeypatch):
"""Test that if an itask has 2 wall_clock triggers with different
offsets that xtrigger manager gets both of them.
Expand All @@ -26,6 +26,12 @@ async def test_2_xtriggers(flow, start, scheduler):
n.b. Clock 3 exists to check the memoization path is followed,
and causing this test to give greater coverage.
"""
task_point = 1588636800 # 2020-05-05
ten_years_ahead = 1904169600 # 2030-05-05
monkeypatch.setattr(
'cylc.flow.xtriggers.wall_clock.time',
lambda: ten_years_ahead - 1
)
id_ = flow({
'scheduler': {
'allow implicit tasks': True
Expand All @@ -49,6 +55,13 @@ async def test_2_xtriggers(flow, start, scheduler):
clock_2_ctx = schd.xtrigger_mgr.get_xtrig_ctx(foo_proxy, 'clock_2')
clock_3_ctx = schd.xtrigger_mgr.get_xtrig_ctx(foo_proxy, 'clock_2')

assert clock_1_ctx.func_kwargs['trigger_time'] == 1588636800
assert clock_2_ctx.func_kwargs['trigger_time'] == 1904169600
assert clock_3_ctx.func_kwargs['trigger_time'] == 1904169600
assert clock_1_ctx.func_kwargs['trigger_time'] == task_point
assert clock_2_ctx.func_kwargs['trigger_time'] == ten_years_ahead
assert clock_3_ctx.func_kwargs['trigger_time'] == ten_years_ahead

schd.xtrigger_mgr.call_xtriggers_async(foo_proxy)
assert foo_proxy.state.xtriggers == {
'clock_1': True,
'clock_2': False,
'clock_3': False,
}

0 comments on commit f926e1d

Please sign in to comment.