"""Unit tests for portfolio steering aggregation.""" from __future__ import annotations from steering.portfolio.aggregate import _sort_attention, _sort_next_work def test_sort_attention_by_severity_then_portfolio_rank(): items = [ {"severity": "info", "portfolio_rank": 0, "title": "B"}, {"severity": "critical", "portfolio_rank": 2, "title": "A"}, {"severity": "warning", "portfolio_rank": 1, "title": "C"}, ] sorted_items = _sort_attention(items) assert sorted_items[0]["severity"] == "critical" assert sorted_items[1]["severity"] == "warning" assert sorted_items[2]["severity"] == "info" def test_sort_next_work_by_portfolio_rank(): items = [ {"portfolio_rank": 2, "title": "Late"}, {"portfolio_rank": 0, "title": "First"}, {"portfolio_rank": None, "title": "Unranked"}, ] sorted_items = _sort_next_work(items) assert sorted_items[0]["title"] == "First" assert sorted_items[1]["title"] == "Late" assert sorted_items[2]["title"] == "Unranked"