Skip to content

Commit 80feb35

Browse files
committed
🔧 Refactor: Update status order and test cases
Modify status order to reflect new workflow and update corresponding test cases. Remove 'In Progress' and 'Stalled' statuses, adjust order of 'Blocked', 'Wontfix', 'Invalid', 'Duplicate', and 'Resolved' statuses. Update test assertions to match new status order and workflow.
1 parent cf0d133 commit 80feb35

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

‎phabfive/status_transitions.py‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
# Statuses like "Wontfix", "Invalid", "Duplicate" are considered terminal/closed states
1515
STATUS_ORDER = {
1616
"open": 0,
17-
"in progress": 1,
18-
"stalled": 2,
19-
"resolved": 3,
20-
"closed": 4,
21-
"wontfix": 5,
22-
"invalid": 6,
23-
"duplicate": 7,
24-
"spite": 8,
17+
"blocked": 1,
18+
"wontfix": 2,
19+
"invalid": 3,
20+
"duplicate": 4,
21+
"resolved": 5,
2522
}
2623

2724

@@ -80,7 +77,9 @@ def matches(self, status_transactions, current_status):
8077
"""
8178
# All conditions must match for the pattern to match
8279
for condition in self.conditions:
83-
if not self._matches_condition(condition, status_transactions, current_status):
80+
if not self._matches_condition(
81+
condition, status_transactions, current_status
82+
):
8483
return False
8584
return True
8685

‎tests/test_status_transitions.py‎

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,25 @@ class TestGetStatusOrder:
1717
def test_open(self):
1818
assert get_status_order("Open") == 0
1919

20-
def test_in_progress(self):
21-
assert get_status_order("In Progress") == 1
22-
23-
def test_stalled(self):
24-
assert get_status_order("Stalled") == 2
25-
26-
def test_resolved(self):
27-
assert get_status_order("Resolved") == 3
28-
29-
def test_closed(self):
30-
assert get_status_order("Closed") == 4
20+
def test_blocked(self):
21+
assert get_status_order("Blocked") == 1
3122

3223
def test_wontfix(self):
33-
assert get_status_order("Wontfix") == 5
24+
assert get_status_order("Wontfix") == 2
3425

3526
def test_invalid(self):
36-
assert get_status_order("Invalid") == 6
27+
assert get_status_order("Invalid") == 3
3728

3829
def test_duplicate(self):
39-
assert get_status_order("Duplicate") == 7
30+
assert get_status_order("Duplicate") == 4
31+
32+
def test_resolved(self):
33+
assert get_status_order("Resolved") == 5
4034

4135
def test_case_insensitive(self):
4236
assert get_status_order("OPEN") == 0
43-
assert get_status_order("resolved") == 3
44-
assert get_status_order("ClOsEd") == 4
37+
assert get_status_order("blocked") == 1
38+
assert get_status_order("ReSOlvEd") == 5
4539

4640
def test_unknown_status(self):
4741
assert get_status_order("Unknown") is None
@@ -87,8 +81,8 @@ def test_parse_been(self):
8781
assert result == {"type": "been", "status": "Resolved"}
8882

8983
def test_parse_never(self):
90-
result = _parse_single_condition("never:Closed")
91-
assert result == {"type": "never", "status": "Closed"}
84+
result = _parse_single_condition("never:Resolved")
85+
assert result == {"type": "never", "status": "Resolved"}
9286

9387
def test_invalid_type(self):
9488
with pytest.raises(PhabfiveException) as exc:
@@ -120,8 +114,8 @@ def test_parse_not_in(self):
120114
assert result == {"type": "in", "status": "Open", "negated": True}
121115

122116
def test_parse_not_from(self):
123-
result = _parse_single_condition("not:from:Closed")
124-
assert result == {"type": "from", "status": "Closed", "negated": True}
117+
result = _parse_single_condition("not:from:Resolved")
118+
assert result == {"type": "from", "status": "Resolved", "negated": True}
125119

126120
def test_parse_not_from_with_direction(self):
127121
result = _parse_single_condition("not:from:Open:raised")
@@ -170,7 +164,7 @@ def test_and_conditions_plus(self):
170164
assert patterns[0].conditions[1] == {"type": "in", "status": "Resolved"}
171165

172166
def test_complex_pattern(self):
173-
patterns = parse_status_patterns("from:Open:raised+in:Resolved,to:Closed")
167+
patterns = parse_status_patterns("from:Open:raised+in:Resolved,to:Wontfix")
174168
assert len(patterns) == 2
175169
# First pattern: AND conditions
176170
assert len(patterns[0].conditions) == 2
@@ -182,7 +176,7 @@ def test_complex_pattern(self):
182176
assert patterns[0].conditions[1] == {"type": "in", "status": "Resolved"}
183177
# Second pattern
184178
assert len(patterns[1].conditions) == 1
185-
assert patterns[1].conditions[0] == {"type": "to", "status": "Closed"}
179+
assert patterns[1].conditions[0] == {"type": "to", "status": "Wontfix"}
186180

187181
def test_empty_pattern(self):
188182
with pytest.raises(PhabfiveException) as exc:
@@ -241,10 +235,10 @@ def test_matches_been_status(self):
241235
pattern = StatusPattern([{"type": "been", "status": "Open"}])
242236

243237
transactions = [
244-
{"oldValue": "Open", "newValue": "Resolved", "dateCreated": 1234567890},
245-
{"oldValue": "Resolved", "newValue": "Closed", "dateCreated": 1234567900}
238+
{"oldValue": "Open", "newValue": "Blocked", "dateCreated": 1234567890},
239+
{"oldValue": "Blocked", "newValue": "Resolved", "dateCreated": 1234567900}
246240
]
247-
current_status = "Closed"
241+
current_status = "Resolved"
248242

249243
assert pattern.matches(transactions, current_status) is True
250244

@@ -308,7 +302,7 @@ def test_matches_and_conditions_fail(self):
308302
"""Test multiple AND conditions fail if any doesn't match"""
309303
pattern = StatusPattern([
310304
{"type": "been", "status": "Open"},
311-
{"type": "in", "status": "Closed"}
305+
{"type": "in", "status": "Wontfix"}
312306
])
313307

314308
transactions = [

0 commit comments

Comments
 (0)