Files
Odoo-Modules/fusion_accounting_followup/tests/test_fusion_followup_level.py
gsinghpal 8eb4b8dc6c fix(fusion_accounting_followup): seeded levels + migration idempotency
- test_create_minimal/negative_delay used sequence=1, which now collides
  with the seeded Friendly Reminder level. Use sequences 901/902.
- migration backfill: search by name (not raw seq) for idempotency,
  allocate sequence as max(existing)+1 to avoid both seed clashes and
  within-batch collisions when Enterprise has duplicate sequence values.

Made-with: Cursor
2026-04-19 21:33:26 -04:00

44 lines
1.7 KiB
Python

from odoo.tests.common import TransactionCase
from odoo.tests import tagged
@tagged('post_install', '-at_install')
class TestFusionFollowupLevel(TransactionCase):
def test_create_minimal(self):
# Note: sequences 1-3 are reserved for seeded default levels.
level = self.env['fusion.followup.level'].create({
'name': 'Reminder', 'sequence': 901, 'delay_days': 7, 'tone': 'gentle',
})
self.assertEqual(level.name, 'Reminder')
self.assertTrue(level.active)
def test_negative_delay_rejected(self):
with self.assertRaises(Exception):
self.env['fusion.followup.level'].create({
'name': 'Bad', 'sequence': 902, 'delay_days': -5, 'tone': 'gentle',
})
def test_duplicate_sequence_rejected(self):
self.env['fusion.followup.level'].create({
'name': 'A', 'sequence': 100, 'delay_days': 7, 'tone': 'gentle',
})
with self.assertRaises(Exception):
self.env['fusion.followup.level'].create({
'name': 'B', 'sequence': 100, 'delay_days': 30, 'tone': 'firm',
})
def test_three_levels_escalate(self):
for seq, name, days, tone in [(1, 'R', 7, 'gentle'),
(2, 'W', 30, 'firm'),
(3, 'L', 60, 'legal')]:
self.env['fusion.followup.level'].create({
'name': name, 'sequence': seq + 200,
'delay_days': days, 'tone': tone,
})
levels = self.env['fusion.followup.level'].search([
('sequence', '>', 200),
], order='sequence')
self.assertEqual(len(levels), 3)
self.assertEqual(levels.mapped('tone'), ['gentle', 'firm', 'legal'])