|
| 1 | +"""Tests for WorkflowSpec.ttl_strategy().""" |
| 2 | + |
1 | 3 | from metaflow.plugins.argo.argo_workflows import WorkflowSpec |
2 | 4 |
|
3 | 5 |
|
4 | | -def test_positive_value(): |
5 | | - spec = WorkflowSpec() |
6 | | - spec.ttl_strategy(86400) |
7 | | - assert spec.payload["ttlStrategy"] == {"secondsAfterCompletion": 86400} |
| 6 | +def test_positive_value_sets_ttl(): |
| 7 | + ws = WorkflowSpec() |
| 8 | + ws.ttl_strategy(604800) |
| 9 | + assert ws.payload["ttlStrategy"] == {"secondsAfterCompletion": 604800} |
| 10 | + |
| 11 | + |
| 12 | +def test_zero_disables_ttl(): |
| 13 | + ws = WorkflowSpec() |
| 14 | + ws.ttl_strategy(0) |
| 15 | + assert "ttlStrategy" not in ws.payload |
8 | 16 |
|
9 | 17 |
|
10 | | -def test_zero_no_ttl(): |
11 | | - spec = WorkflowSpec() |
12 | | - spec.ttl_strategy(0) |
13 | | - assert "ttlStrategy" not in spec.payload |
| 18 | +def test_none_disables_ttl(): |
| 19 | + ws = WorkflowSpec() |
| 20 | + ws.ttl_strategy(None) |
| 21 | + assert "ttlStrategy" not in ws.payload |
14 | 22 |
|
15 | 23 |
|
16 | | -def test_none_no_ttl(): |
17 | | - spec = WorkflowSpec() |
18 | | - spec.ttl_strategy(None) |
19 | | - assert "ttlStrategy" not in spec.payload |
| 24 | +def test_negative_disables_ttl(): |
| 25 | + ws = WorkflowSpec() |
| 26 | + ws.ttl_strategy(-1) |
| 27 | + assert "ttlStrategy" not in ws.payload |
20 | 28 |
|
21 | 29 |
|
22 | 30 | def test_string_value_converted_to_int(): |
23 | | - spec = WorkflowSpec() |
24 | | - spec.ttl_strategy("86400") |
25 | | - assert spec.payload["ttlStrategy"] == {"secondsAfterCompletion": 86400} |
| 31 | + ws = WorkflowSpec() |
| 32 | + ws.ttl_strategy("86400") |
| 33 | + assert ws.payload["ttlStrategy"] == {"secondsAfterCompletion": 86400} |
26 | 34 |
|
27 | 35 |
|
28 | | -def test_negative_value_no_ttl(): |
29 | | - spec = WorkflowSpec() |
30 | | - spec.ttl_strategy(-1) |
31 | | - assert "ttlStrategy" not in spec.payload |
| 36 | +def test_chaining(): |
| 37 | + """ttl_strategy returns self for method chaining.""" |
| 38 | + ws = WorkflowSpec() |
| 39 | + result = ws.ttl_strategy(3600) |
| 40 | + assert result is ws |
0 commit comments