Files
Odoo-Modules/fusion_accounting_assets/tests/test_asset_tools.py
2026-04-19 17:16:22 -04:00

57 lines
2.3 KiB
Python

"""Tests for the 5 fusion-asset AI tools."""
from datetime import date
from odoo.tests import tagged
from odoo.tests.common import TransactionCase
from odoo.addons.fusion_accounting_ai.services.tools import asset_management as tools
@tagged('post_install', '-at_install')
class TestFusionAssetTools(TransactionCase):
def test_fusion_list_assets(self):
self.env['fusion.asset'].create({
'name': 'Tool Test', 'cost': 1000,
'acquisition_date': date(2026, 1, 1),
'method': 'straight_line', 'useful_life_years': 4,
})
result = tools.fusion_list_assets(self.env, {'company_id': self.env.company.id})
self.assertGreaterEqual(result.get('count', 0), 1)
def test_fusion_get_asset_detail(self):
asset = self.env['fusion.asset'].create({
'name': 'Detail Test', 'cost': 1500,
'acquisition_date': date(2026, 1, 1),
'method': 'straight_line', 'useful_life_years': 4,
})
result = tools.fusion_get_asset_detail(self.env, {'asset_id': asset.id})
self.assertEqual(result['asset']['name'], 'Detail Test')
def test_fusion_compute_schedule(self):
asset = self.env['fusion.asset'].create({
'name': 'Schedule Test', 'cost': 2000,
'acquisition_date': date(2026, 1, 1),
'method': 'straight_line', 'useful_life_years': 4,
})
result = tools.fusion_compute_asset_schedule(self.env, {'asset_id': asset.id})
self.assertEqual(result['lines_created'], 4)
def test_fusion_suggest_useful_life(self):
self.env['ir.config_parameter'].sudo().search([
('key', 'in', ['fusion_accounting.provider.asset_useful_life',
'fusion_accounting.provider.default'])
]).unlink()
result = tools.fusion_suggest_asset_useful_life(self.env, {
'description': 'desk',
})
self.assertEqual(result['useful_life_years'], 7)
def test_tools_registered_in_dispatch(self):
from odoo.addons.fusion_accounting_ai.services.tools import TOOL_DISPATCH
for tool_name in ['fusion_list_assets', 'fusion_get_asset_detail',
'fusion_compute_asset_schedule', 'fusion_dispose_asset',
'fusion_suggest_asset_useful_life']:
self.assertIn(tool_name, TOOL_DISPATCH)