Skip to content

Commit 0572d43

Browse files
author
Nissan Pow
committed
test: add unit tests for WorkflowSpec.ttl_strategy()
1 parent 1d40d2a commit 0572d43

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1+
"""Tests for WorkflowSpec.ttl_strategy()."""
2+
13
from metaflow.plugins.argo.argo_workflows import WorkflowSpec
24

35

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
816

917

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
1422

1523

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
2028

2129

2230
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}
2634

2735

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

Comments
 (0)