feat(1c): add brief delta analysis and changes page
This commit is contained in:
@@ -74,6 +74,66 @@ class ManagerBriefTests(unittest.TestCase):
|
||||
self.assertIn("## Компании риска", md)
|
||||
self.assertIn("ФЕЛИЦТ ГРУПП 2026", md)
|
||||
|
||||
def test_compute_delta_context(self) -> None:
|
||||
previous_artifact = {
|
||||
"generated_at": "2026-05-22T09:00:00+00:00",
|
||||
"context": {
|
||||
"generated_at": "2026-05-22T09:00:00+00:00",
|
||||
"portfolio_summary": {
|
||||
"companies_total": 40,
|
||||
"critical_total": 8,
|
||||
"high_total": 18,
|
||||
"busy_total": 6,
|
||||
"open_cases_total": 10,
|
||||
"detections_total": 18,
|
||||
"activity_30d_total": 12000.0,
|
||||
"activity_forecast_30d_total": 50000.0,
|
||||
},
|
||||
"watchlist": [{"infobase": "ИБ1", "counterparty": "СТАРАЯ КОМПАНИЯ"}],
|
||||
"portfolio_snapshot": [
|
||||
{
|
||||
"infobase": "ИБ1",
|
||||
"counterparty": "ФЕЛИЦТ ГРУПП 2026",
|
||||
"normalized_counterparty": "ФЕЛИЦТ ГРУПП",
|
||||
"registry_match_mode": "manual",
|
||||
"signal_severity": "high",
|
||||
"signal_score": 70,
|
||||
"current_status": "idle",
|
||||
"active_locks": 1,
|
||||
"days_since_last_activity": 0,
|
||||
"amount_30d": 100.0,
|
||||
"amount_forecast_30d": 200.0,
|
||||
"open_cases_total": 1,
|
||||
"detections_total": 2,
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
current = dict(self.context)
|
||||
current["generated_at"] = "2026-05-22T12:00:00+00:00"
|
||||
current["portfolio_snapshot"] = [
|
||||
{
|
||||
"infobase": "ИБ1",
|
||||
"counterparty": "ФЕЛИЦТ ГРУПП 2026",
|
||||
"normalized_counterparty": "ФЕЛИЦТ ГРУПП",
|
||||
"registry_match_mode": "manual",
|
||||
"signal_severity": "critical",
|
||||
"signal_score": 95,
|
||||
"current_status": "busy",
|
||||
"active_locks": 3,
|
||||
"days_since_last_activity": 0,
|
||||
"amount_30d": 100.0,
|
||||
"amount_forecast_30d": 150.0,
|
||||
"open_cases_total": 4,
|
||||
"detections_total": 5,
|
||||
}
|
||||
]
|
||||
delta = gmb.compute_delta_context(current, previous_artifact)
|
||||
self.assertTrue(delta["available"])
|
||||
self.assertEqual(delta["summary"]["critical_total_delta"], 2)
|
||||
self.assertIn("ФЕЛИЦТ ГРУПП 2026", delta["new_critical"])
|
||||
self.assertEqual(delta["top_changes"][0]["change_type"], "severity_up")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user