test(fusion_claims,fusion_tasks): fix clone-test failures (future dates + seed-aware asserts)
Real install verified on the Westin clone; these were test-only bugs:
- Task-create tests hardcoded scheduled_date 2026-06-03, now in the past, which
the base _check_no_overlap rejects ('Cannot schedule tasks in the past'). Use
future dates (tz test pins a future July date so Toronto stays EDT for the
9:00->13:00 UTC assertion).
- Service-rate resolver tests created rows with seeded codes (callout_standard_normal,
per_km) -> UNIQUE(code) violation post-install. Assert against the seed instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from datetime import date
|
||||
from datetime import date, timedelta
|
||||
from odoo.tests.common import TransactionCase, tagged
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class TestServiceBooking(TransactionCase):
|
||||
t = self.Task.create({
|
||||
'task_type': 'repair',
|
||||
'technician_id': self.tech.id,
|
||||
'scheduled_date': date(2026, 6, 3),
|
||||
'scheduled_date': date.today() + timedelta(days=7),
|
||||
'description': 'Test repair',
|
||||
'is_in_store': True,
|
||||
})
|
||||
@@ -63,7 +63,7 @@ class TestServiceBooking(TransactionCase):
|
||||
'street': '88 Bloor St E', 'city': 'Toronto'},
|
||||
'category': 'standard', 'timing': 'normal', 'in_shop': False,
|
||||
'device': 'scooter', 'issue': "won't power on",
|
||||
'date': '2026-06-03', 'time_start': 9.0, 'duration_hr': 1.0,
|
||||
'date': (date.today() + timedelta(days=7)).strftime('%Y-%m-%d'), 'time_start': 9.0, 'duration_hr': 1.0,
|
||||
'technician_id': self.tech.id, 'description': 'check battery',
|
||||
}
|
||||
res = self.Task.action_book_from_wizard(payload)
|
||||
|
||||
@@ -20,17 +20,22 @@ class TestServiceRate(TransactionCase):
|
||||
return self.Rate.create(vals)
|
||||
|
||||
def test_get_callout_matches_category_and_timing(self):
|
||||
r = self._make(code='callout_standard_normal', category='standard', timing='normal', price=95.0)
|
||||
self._make(code='callout_lift_normal', category='lift', timing='normal', price=160.0)
|
||||
self.assertEqual(self.Rate.get_callout('standard', 'normal'), r)
|
||||
# Assert against the real seed (codes are unique, so creating colliding
|
||||
# standard/normal rows would violate the UNIQUE(code) constraint).
|
||||
r = self.Rate.get_callout('standard', 'normal')
|
||||
self.assertTrue(r)
|
||||
self.assertEqual(r.code, 'callout_standard_normal')
|
||||
self.assertEqual(r.rate_kind, 'callout')
|
||||
|
||||
def test_get_callout_in_shop_returns_empty(self):
|
||||
self._make(code='callout_standard_normal_b')
|
||||
self.assertFalse(self.Rate.get_callout('standard', 'normal', in_shop=True))
|
||||
|
||||
def test_get_rate_by_code(self):
|
||||
r = self._make(code='per_km', rate_kind='travel', category='na', timing='na', unit='per_km', price=0.70)
|
||||
self.assertEqual(self.Rate.get_rate('per_km'), r)
|
||||
# 'per_km' is a seeded code; the resolver returns that row.
|
||||
r = self.Rate.get_rate('per_km')
|
||||
self.assertTrue(r)
|
||||
self.assertEqual(r.unit, 'per_km')
|
||||
|
||||
def test_code_must_be_unique(self):
|
||||
self._make(code='dup')
|
||||
|
||||
@@ -21,9 +21,12 @@ class TestTaskTz(TransactionCase):
|
||||
'login': 'tz_test_tech_svcbook',
|
||||
'x_fc_is_field_staff': True,
|
||||
})
|
||||
# A FUTURE date in July so the task is not "in the past" (the base
|
||||
# _check_no_overlap constraint rejects past dates) and Toronto is firmly
|
||||
# in EDT (-4), keeping the 9:00 -> 13:00 UTC assertion deterministic.
|
||||
cls.task = cls.env['fusion.technician.task'].create({
|
||||
'technician_id': cls.tech.id,
|
||||
'scheduled_date': date(2026, 6, 3),
|
||||
'scheduled_date': date(date.today().year + 1, 7, 1),
|
||||
'time_start': 9.0,
|
||||
'time_end': 10.0,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user