Skip to content

Commit

Permalink
Drop old timesensitive tests that no longer apply
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Feb 25, 2025
1 parent 5095969 commit 71f8d85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 56 deletions.
4 changes: 4 additions & 0 deletions src/rules/team/timesensitive_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class RICEBlock(Block):
"""A special case blocks that sorts its issues by RICE score"""

def yield_issues(self):
if not self.issues:
return
rice_field_id = self.issues[0].raw["Context"]["Field Ids"]["RICE Score"]
rice = lambda issue: float(getattr(issue.fields, rice_field_id) or "0")
yield from sorted(self.issues, key=rice, reverse=True)
Expand All @@ -124,6 +126,8 @@ class DueDateBlock(Block):

def yield_issues(self):
"""Within the DueDate block, issues get sorted by due date"""
if not self.issues:
return
duedate_field_id = self.issues[0].raw["Context"]["Field Ids"]["Due Date"]
duedate = lambda issue: getattr(issue.fields, duedate_field_id) or "9999-99-99"
yield from sorted(self.issues, key=duedate)
Expand Down
6 changes: 4 additions & 2 deletions src/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@


class MockIssue:
def __init__(self, idx, project, parent, rank, priority="Undefined", duedate=None):
def __init__(self, idx, project, parent, rank, priority="Undefined", duedate=None, rice=None):
raw = {}
raw["Context"] = {}
raw["Context"]["Field Ids"] = {}
raw["Context"]["Field Ids"]["Rank"] = "rank"
raw["Context"]["Field Ids"]["Due Date"] = "duedate"
raw["Context"]["Field Ids"]["RICE Score"] = "rice"
raw["Context"]["Related Issues"] = {}
raw["Context"]["Related Issues"]["Parent"] = parent

Expand All @@ -22,9 +23,10 @@ def __init__(self, idx, project, parent, rank, priority="Undefined", duedate=Non
self.fields.rank = rank
self.fields.duedate = duedate
self.fields.priority.name = priority
self.fields.rice = rice

def __repr__(self):
return f"<{type(self).__name__} {self.fields.project.key}-{self.idx}({self.fields.rank})>"
return f"<{type(self).__name__} {self.fields.project.key}-{self.idx}({self.fields.rank}){self.fields.duedate or ''}>"


@pytest.fixture
Expand Down
54 changes: 0 additions & 54 deletions src/tests/test_timesensitive_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,3 @@ def test_rank_idempotence(issues):
blocks.sort()
new_ranking = blocks.get_issues()
assert new_ranking == old_ranking


def test_rank_single_move(issues):
issues["child3"].raw["Context"]["Related Issues"]["Parent"].fields.rank = -1
blocks = rules.team.timesensitive_rank.Blocks(list(issues.values()))
old_ranking = blocks.get_issues()
blocks.sort()
new_ranking = blocks.get_issues()
assert new_ranking != old_ranking
assert new_ranking[0].key == "child3"
assert new_ranking[1].key == "child1"
assert new_ranking[2].key == "child2"
# Highly ranked orphan child is not maintained
assert new_ranking[3].key == "child0"
assert new_ranking[4].key == "child4"


def test_rank_with_dates(issues_with_due_dates):
issues = issues_with_due_dates
issues["child3"].raw["Context"]["Related Issues"]["Parent"].fields.rank = -1
blocks = rules.team.timesensitive_rank.Blocks(list(issues.values()))
old_ranking = blocks.get_issues()
blocks.sort()
new_ranking = blocks.get_issues()
import pprint

pprint.pprint(new_ranking)
assert new_ranking != old_ranking
assert new_ranking[0].key == "child5"
assert new_ranking[1].key == "child4"
assert new_ranking[2].key == "child2"
assert new_ranking[3].key == "child3"
assert new_ranking[4].key == "child1"


def test_rank_with_priorities(issues_with_priorities):
issues = list(issues_with_priorities.values())
blocks = rules.team.timesensitive_rank.Blocks(issues)
blocks.sort()
new_ranking = blocks.get_issues()
expected = [
"child6",
"child5",
"child7",
"child8",
"child9",
"child2",
"child4",
"child3",
"child1",
"child0",
]
actual = [issue.key for issue in new_ranking]
assert actual == expected

0 comments on commit 71f8d85

Please sign in to comment.