19
19
import pytest
20
20
from metomi .isodatetime .data import TimePoint
21
21
22
+ from cylc .flow .cycling .integer import IntegerPoint
22
23
from cylc .flow .workflow_status import (
23
- StopMode ,
24
- WorkflowStatus ,
25
24
WORKFLOW_STATUS_RUNNING_TO_HOLD ,
26
25
WORKFLOW_STATUS_RUNNING_TO_STOP ,
26
+ StopMode ,
27
+ WorkflowStatus ,
27
28
get_workflow_status ,
28
29
get_workflow_status_msg ,
29
30
)
30
31
31
-
32
32
STOP_TIME = TimePoint (year = 2006 ).to_local_time_zone ()
33
33
34
34
@@ -79,29 +79,29 @@ def schd(
79
79
'stopping: waiting for active jobs to complete'
80
80
),
81
81
(
82
- {'hold_point' : 'point' },
82
+ {'hold_point' : 2 },
83
83
WorkflowStatus .RUNNING ,
84
- WORKFLOW_STATUS_RUNNING_TO_HOLD % 'point'
84
+ WORKFLOW_STATUS_RUNNING_TO_HOLD % 2
85
85
),
86
86
(
87
- {'stop_point' : 'point' },
87
+ {'stop_point' : 4 },
88
88
WorkflowStatus .RUNNING ,
89
- WORKFLOW_STATUS_RUNNING_TO_STOP % 'point'
89
+ WORKFLOW_STATUS_RUNNING_TO_STOP % 4
90
90
),
91
91
(
92
92
{'stop_clock_time' : int (STOP_TIME .seconds_since_unix_epoch )},
93
93
WorkflowStatus .RUNNING ,
94
94
WORKFLOW_STATUS_RUNNING_TO_STOP % str (STOP_TIME )
95
95
),
96
96
(
97
- {'stop_task_id' : 'foo' },
97
+ {'stop_task_id' : '6/ foo' },
98
98
WorkflowStatus .RUNNING ,
99
- WORKFLOW_STATUS_RUNNING_TO_STOP % 'foo'
99
+ WORKFLOW_STATUS_RUNNING_TO_STOP % '6/ foo'
100
100
),
101
101
(
102
- {'final_point' : 'point' },
102
+ {'final_point' : 8 },
103
103
WorkflowStatus .RUNNING ,
104
- WORKFLOW_STATUS_RUNNING_TO_STOP % 'point'
104
+ WORKFLOW_STATUS_RUNNING_TO_STOP % 8
105
105
),
106
106
(
107
107
{'is_stalled' : True },
@@ -128,11 +128,48 @@ def schd(
128
128
(
129
129
{'is_stalled' : True , 'is_paused' : True },
130
130
WorkflowStatus .PAUSED ,
131
- 'stalled (paused)'
131
+ 'stalled and paused' ,
132
+ ),
133
+ (
134
+ # earliest of stop point, hold point and stop task id
135
+ {
136
+ 'stop_point' : IntegerPoint (4 ),
137
+ 'hold_point' : IntegerPoint (2 ),
138
+ 'stop_task_id' : '6/foo' ,
139
+ },
140
+ WorkflowStatus .RUNNING ,
141
+ WORKFLOW_STATUS_RUNNING_TO_HOLD % 2 ,
142
+ ),
143
+ (
144
+ {
145
+ 'stop_point' : IntegerPoint (11 ),
146
+ 'hold_point' : IntegerPoint (15 ),
147
+ 'stop_task_id' : '9/bar' ,
148
+ },
149
+ WorkflowStatus .RUNNING ,
150
+ WORKFLOW_STATUS_RUNNING_TO_STOP % '9/bar' ,
151
+ ),
152
+ (
153
+ {
154
+ 'stop_point' : IntegerPoint (3 ),
155
+ 'hold_point' : IntegerPoint (3 ),
156
+ },
157
+ WorkflowStatus .RUNNING ,
158
+ WORKFLOW_STATUS_RUNNING_TO_STOP % 3 ,
159
+ ),
160
+ (
161
+ # stop point trumps final point
162
+ {
163
+ 'stop_point' : IntegerPoint (1 ),
164
+ 'final_point' : IntegerPoint (2 ),
165
+ },
166
+ WorkflowStatus .RUNNING ,
167
+ WORKFLOW_STATUS_RUNNING_TO_STOP % 1 ,
132
168
),
133
169
]
134
170
)
135
- def test_get_workflow_status (kwargs , state , message ):
171
+ def test_get_workflow_status (kwargs , state , message , set_cycling_type ):
172
+ set_cycling_type ()
136
173
scheduler = schd (** kwargs )
137
174
assert get_workflow_status (scheduler ) == state
138
175
assert get_workflow_status_msg (scheduler ) == message
0 commit comments