|
10 | 10 | from primer.common.config import settings |
11 | 11 | from primer.common.models import Engineer, SessionFacets, SessionWorkflowProfile, Team |
12 | 12 | from primer.common.pricing import get_pricing |
| 13 | +from primer.common.schemas import ModelChoiceOpportunity |
13 | 14 |
|
14 | 15 | # --------------------------------------------------------------------------- |
15 | 16 | # Helpers |
@@ -766,6 +767,44 @@ def test_team_lead_access(self, client, db_session): |
766 | 767 | r = client.get("/api/v1/finops/cost-modeling", headers={"x-api-key": key}) |
767 | 768 | assert r.status_code == 200 |
768 | 769 |
|
| 770 | + def test_model_choice_opportunities_sort_high_confidence_first(self): |
| 771 | + from primer.server.services.finops_service import _model_choice_opportunity_sort_key |
| 772 | + |
| 773 | + high = ModelChoiceOpportunity( |
| 774 | + workflow_archetype="debugging", |
| 775 | + current_model="claude-opus-4-20250514", |
| 776 | + recommended_model="claude-sonnet-4-5-20250929", |
| 777 | + current_session_count=6, |
| 778 | + supporting_session_count=8, |
| 779 | + current_success_rate=0.82, |
| 780 | + recommended_success_rate=0.83, |
| 781 | + current_avg_cost=2.4, |
| 782 | + recommended_avg_cost=1.2, |
| 783 | + period_savings_estimate=3.5, |
| 784 | + monthly_savings_estimate=7.0, |
| 785 | + confidence="high", |
| 786 | + rationale="High-confidence opportunity.", |
| 787 | + ) |
| 788 | + low = ModelChoiceOpportunity( |
| 789 | + workflow_archetype="feature_development", |
| 790 | + current_model="claude-opus-4-20250514", |
| 791 | + recommended_model="claude-sonnet-4-5-20250929", |
| 792 | + current_session_count=2, |
| 793 | + supporting_session_count=2, |
| 794 | + current_success_rate=0.82, |
| 795 | + recommended_success_rate=0.82, |
| 796 | + current_avg_cost=2.4, |
| 797 | + recommended_avg_cost=1.2, |
| 798 | + period_savings_estimate=3.5, |
| 799 | + monthly_savings_estimate=7.0, |
| 800 | + confidence="low", |
| 801 | + rationale="Low-confidence opportunity.", |
| 802 | + ) |
| 803 | + |
| 804 | + ordered = sorted([low, high], key=_model_choice_opportunity_sort_key) |
| 805 | + |
| 806 | + assert ordered[0].confidence == "high" |
| 807 | + |
769 | 808 |
|
770 | 809 | # --------------------------------------------------------------------------- |
771 | 810 | # Cost Forecasting |
|
0 commit comments