@@ -128,9 +128,15 @@ def test_filter_ids_task_mode(task_pool, ids, matched, not_matched):
128
128
{}
129
129
)
130
130
131
- _matched , _not_matched = filter_ids (pool , ids )
131
+ _matched , _not_matched , _invalid = filter_ids (
132
+ pool ,
133
+ ids ,
134
+ IntegerPoint ('1' ),
135
+ IntegerPoint ('1' ),
136
+ )
132
137
assert [get_task_id (itask ) for itask in _matched ] == matched
133
138
assert _not_matched == not_matched
139
+ assert not _invalid
134
140
135
141
136
142
@pytest .mark .parametrize (
@@ -189,22 +195,43 @@ def test_filter_ids_cycle_mode(task_pool, ids, matched, not_matched):
189
195
{}
190
196
)
191
197
192
- _matched , _not_matched = filter_ids (pool , ids , out = IDTokens .Cycle )
198
+ _matched , _not_matched , _invalid = filter_ids (
199
+ pool ,
200
+ ids ,
201
+ IntegerPoint ('1' ),
202
+ IntegerPoint ('1' ),
203
+ out = IDTokens .Cycle ,
204
+ )
193
205
assert _matched == [IntegerPoint (i ) for i in matched ]
194
206
assert _not_matched == not_matched
207
+ assert not _invalid
195
208
196
209
197
210
def test_filter_ids_invalid (caplog ):
198
211
"""Ensure invalid IDs are handled elegantly."""
199
- matched , not_matched = filter_ids ({}, ['#' ])
200
- assert matched == []
201
- assert not_matched == ['#' ]
212
+ _matched , _not_matched , _invalid = filter_ids (
213
+ {},
214
+ ['#' ],
215
+ IntegerPoint ('1' ),
216
+ IntegerPoint ('1' ),
217
+ )
218
+ assert _matched == []
219
+ assert _not_matched == ['#' ]
220
+ assert not _invalid
202
221
assert caplog .record_tuples == [
203
222
('cylc' , 30 , 'No active tasks matching: #' ),
204
223
]
224
+
205
225
caplog .clear ()
206
- matched , not_matched = filter_ids ({}, ['#' ], warn = False )
226
+ _matched , _not_matched , _invalid = filter_ids (
227
+ {},
228
+ ['#' ],
229
+ IntegerPoint ('1' ),
230
+ IntegerPoint ('1' ),
231
+ warn = False ,
232
+ )
207
233
assert caplog .record_tuples == []
234
+ assert not _invalid
208
235
209
236
210
237
def test_filter_ids_pattern_match_off (task_pool ):
@@ -216,14 +243,17 @@ def test_filter_ids_pattern_match_off(task_pool):
216
243
{}
217
244
)
218
245
219
- _matched , _not_matched = filter_ids (
246
+ _matched , _not_matched , _invalid = filter_ids (
220
247
pool ,
221
248
['1/a' ],
249
+ IntegerPoint ('1' ),
250
+ IntegerPoint ('1' ),
222
251
out = IDTokens .Task ,
223
252
pattern_match = False ,
224
253
)
225
254
assert [get_task_id (itask ) for itask in _matched ] == ['1/a:x' ]
226
255
assert _not_matched == []
256
+ assert not _invalid
227
257
228
258
229
259
def test_filter_ids_toggle_pattern_matching (task_pool , caplog ):
@@ -238,25 +268,31 @@ def test_filter_ids_toggle_pattern_matching(task_pool, caplog):
238
268
ids = ['*/*' ]
239
269
240
270
# ensure pattern matching works
241
- _matched , _not_matched = filter_ids (
271
+ _matched , _not_matched , _invalid = filter_ids (
242
272
pool ,
243
273
ids ,
274
+ IntegerPoint ('1' ),
275
+ IntegerPoint ('1' ),
244
276
out = IDTokens .Task ,
245
277
pattern_match = True ,
246
278
)
247
279
assert [get_task_id (itask ) for itask in _matched ] == ['1/a:x' ]
248
280
assert _not_matched == []
281
+ assert not _invalid
249
282
250
283
# ensure pattern matching can be disabled
251
284
caplog .clear ()
252
- _matched , _not_matched = filter_ids (
285
+ _matched , _not_matched , _invalid = filter_ids (
253
286
pool ,
254
287
ids ,
288
+ IntegerPoint ('1' ),
289
+ IntegerPoint ('1' ),
255
290
out = IDTokens .Task ,
256
291
pattern_match = False ,
257
292
)
258
293
assert [get_task_id (itask ) for itask in _matched ] == []
259
294
assert _not_matched == ['*/*' ]
295
+ assert not _invalid
260
296
261
297
# ensure the ID is logged
262
298
assert len (caplog .record_tuples ) == 1
@@ -285,36 +321,56 @@ def test_filter_ids_namespace_hierarchy(task_pool, ids, matched, not_matched):
285
321
},
286
322
)
287
323
288
- _matched , _not_matched = filter_ids (
324
+ _matched , _not_matched , _invalid = filter_ids (
289
325
pool ,
290
326
ids ,
327
+ IntegerPoint ('1' ),
328
+ IntegerPoint ('1' ),
291
329
pattern_match = False ,
292
330
)
293
331
294
332
assert [get_task_id (itask ) for itask in _matched ] == matched
295
333
assert _not_matched == not_matched
334
+ assert not _invalid
296
335
297
336
298
337
def test_filter_ids_out_format ():
299
- filter_ids ({}, [], out = IDTokens .Cycle )
338
+ filter_ids (
339
+ {},
340
+ [],
341
+ IntegerPoint ('1' ),
342
+ IntegerPoint ('1' ),
343
+ out = IDTokens .Cycle ,
344
+ )
300
345
with pytest .raises (ValueError ):
301
- filter_ids ({}, [], out = IDTokens .Job )
346
+ filter_ids (
347
+ {},
348
+ [],
349
+ IntegerPoint ('1' ),
350
+ IntegerPoint ('1' ),
351
+ out = IDTokens .Job ,
352
+ )
302
353
303
354
304
355
def test_filter_ids_log_errors (caplog ):
305
- _ , _not_matched = filter_ids ({}, ['/////' ])
306
- assert _not_matched == ['/////' ]
356
+ * _ , _invalid = filter_ids (
357
+ {},
358
+ ['/////' ],
359
+ IntegerPoint ('1' ),
360
+ IntegerPoint ('1' ),
361
+ )
362
+ assert _invalid == ['/////' ]
307
363
assert caplog .record_tuples == [('cylc' , 30 , 'Invalid ID: /////' )]
308
364
309
365
310
366
@pytest .mark .parametrize (
311
367
'point, value, pattern_match, expected' ,
312
368
[
313
- (IntegerPoint (23 ), '23' , True , True ),
314
- (IntegerPoint (23 ), '23' , False , True ),
315
- (IntegerPoint (23 ), '2*' , True , True ),
316
- (IntegerPoint (23 ), '2*' , False , False ),
317
- (IntegerPoint (23 ), '2a' , True , False ),
369
+ (IntegerPoint ('23' ), '23' , True , True ),
370
+ (IntegerPoint ('23' ), '23' , False , True ),
371
+ (IntegerPoint ('23' ), '2*' , True , True ),
372
+ (IntegerPoint ('23' ), '2*' , False , False ),
373
+ (IntegerPoint ('23' ), '2a' , True , False ),
318
374
(ISO8601Point ('2049-01-01T00:00Z' ), '2049' , True , True ),
319
375
(ISO8601Point ('2049-01-01T00:00Z' ), '2049' , False , True ),
320
376
(ISO8601Point ('2049-03-01T00:00Z' ), '2049' , True , False ),
0 commit comments