feat(fusion_accounting_reports): commentary_prompt for LLM-generated narratives
Made-with: Cursor
This commit is contained in:
@@ -6,4 +6,5 @@ from . import test_drill_down_resolver
|
||||
from . import test_fusion_report_engine
|
||||
from . import test_seeded_reports
|
||||
from . import test_anomaly_detection
|
||||
from . import test_commentary_prompt
|
||||
from . import test_commentary_generator
|
||||
|
||||
50
fusion_accounting_reports/tests/test_commentary_prompt.py
Normal file
50
fusion_accounting_reports/tests/test_commentary_prompt.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""Tests for commentary_prompt module."""
|
||||
|
||||
from odoo.tests.common import TransactionCase, tagged
|
||||
from odoo.addons.fusion_accounting_reports.services.commentary_prompt import (
|
||||
SYSTEM_PROMPT, build_prompt,
|
||||
)
|
||||
|
||||
|
||||
@tagged('post_install', '-at_install')
|
||||
class TestCommentaryPrompt(TransactionCase):
|
||||
|
||||
def test_system_prompt_requires_json(self):
|
||||
self.assertIn('JSON', SYSTEM_PROMPT)
|
||||
self.assertIn('"summary"', SYSTEM_PROMPT)
|
||||
self.assertIn('"highlights"', SYSTEM_PROMPT)
|
||||
|
||||
def test_build_prompt_returns_tuple(self):
|
||||
report = {'report_name': 'P&L', 'period': {'label': 'Apr 2026',
|
||||
'date_from': '2026-04-01',
|
||||
'date_to': '2026-04-30'},
|
||||
'rows': []}
|
||||
result = build_prompt(report, [])
|
||||
self.assertEqual(len(result), 2)
|
||||
self.assertIn('REPORT', result[1])
|
||||
self.assertIn('Apr 2026', result[1])
|
||||
|
||||
def test_user_prompt_includes_rows(self):
|
||||
report = {
|
||||
'report_name': 'P&L',
|
||||
'period': {'label': 'X', 'date_from': 'a', 'date_to': 'b'},
|
||||
'rows': [
|
||||
{'id': 'r1', 'label': 'Revenue', 'amount': 100000.50},
|
||||
{'id': 'r2', 'label': 'Net Income', 'amount': 25000, 'is_subtotal': True},
|
||||
],
|
||||
}
|
||||
_, user = build_prompt(report, [])
|
||||
self.assertIn('Revenue', user)
|
||||
self.assertIn('100,000.50', user)
|
||||
self.assertIn('SUBTOTAL', user)
|
||||
|
||||
def test_user_prompt_includes_anomalies(self):
|
||||
report = {'report_name': 'X', 'period': {'label': 'X', 'date_from': '', 'date_to': ''}, 'rows': []}
|
||||
anomalies = [
|
||||
{'label': 'Revenue', 'direction': 'increase', 'variance_pct': 25.0,
|
||||
'variance_amount': 5000, 'severity': 'medium'},
|
||||
]
|
||||
_, user = build_prompt(report, anomalies)
|
||||
self.assertIn('ANOMALIES', user)
|
||||
self.assertIn('Revenue', user)
|
||||
self.assertIn('25.0%', user)
|
||||
Reference in New Issue
Block a user