Files
Odoo-Modules/fusion_accounting_reports/tests/test_reports_adapter.py
gsinghpal 15cf4e129f feat(fusion_accounting_ai): wire ReportsAdapter fusion paths to engine
Adds three new method families on ReportsAdapter that route through
fusion.report.engine when fusion_accounting_reports is installed:

- run_fusion_report (pnl/balance_sheet/trial_balance/general_ledger)
- get_anomalies (variance detection on engine output)
- get_commentary (LLM narrative; falls back to templated)

These coexist with the legacy ref_id-shaped run_report / export_report
API so existing reporting tools (profit_loss, balance_sheet, etc.) keep
working unchanged. FUSION_MODEL is updated to fusion.report.engine so
mode detection picks FUSION when the new engine is installed.

4 new TransactionCase tests cover the fusion + community paths.

Made-with: Cursor
2026-04-19 15:39:54 -04:00

57 lines
1.8 KiB
Python

"""Tests for ReportsAdapter Phase-2 (engine-routed) methods."""
from odoo.tests.common import TransactionCase, tagged
from odoo.addons.fusion_accounting_ai.services.data_adapters.reports import (
ReportsAdapter,
)
@tagged('post_install', '-at_install')
class TestReportsAdapter(TransactionCase):
def setUp(self):
super().setUp()
self.adapter = ReportsAdapter(self.env)
def test_run_fusion_report_via_fusion_pnl(self):
result = self.adapter.run_fusion_report_via_fusion(
report_type='pnl',
date_from='2026-01-01',
date_to='2026-12-31',
company_id=self.env.company.id,
)
self.assertEqual(result.get('report_type'), 'pnl')
self.assertIn('rows', result)
def test_run_fusion_report_via_community_returns_error(self):
result = self.adapter.run_fusion_report_via_community(
report_type='pnl',
date_from='2026-01-01',
date_to='2026-12-31',
)
self.assertIn('error', result)
def test_get_anomalies_via_fusion(self):
result = self.adapter.get_anomalies_via_fusion(
report_type='pnl',
date_from='2026-01-01',
date_to='2026-12-31',
comparison='previous_year',
company_id=self.env.company.id,
)
self.assertIn('anomalies', result)
self.assertIsInstance(result['anomalies'], list)
def test_get_commentary_via_fusion(self):
result = self.adapter.get_commentary_via_fusion(
report_type='pnl',
date_from='2026-01-01',
date_to='2026-12-31',
company_id=self.env.company.id,
)
self.assertIn('summary', result)
self.assertIn('highlights', result)
self.assertIn('concerns', result)
self.assertIn('next_actions', result)