Skip to content

Commit

Permalink
improve tests cov
Browse files Browse the repository at this point in the history
  • Loading branch information
RPSJR committed Oct 28, 2024
1 parent 6a5b134 commit e261302
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def setUpClass(cls):
cls.inspection_template = cls.env["fleet.vehicle.inspection.template"]
cls.vehicle = cls.env.ref("fleet.vehicle_5").id

cls.item_01 = cls.inspection_item.create({"name": "Lights"})
cls.item_01 = cls.inspection_item.create({"name": "Lights", "sequence": 1})

cls.item_02 = cls.inspection_item.create({"name": "Mirrors"})
cls.item_02 = cls.inspection_item.create({"name": "Mirrors", "sequence": 2})

cls.inspection_template = cls.inspection_template.create(
{
Expand All @@ -24,7 +24,10 @@ def setUpClass(cls):
(
0,
0,
{"inspection_template_item_id": cls.item_01.id},
{
"inspection_template_item_id": cls.item_01.id,
"sequence": 5, # Different sequence in the template line
},
),
(
0,
Expand All @@ -43,7 +46,23 @@ def setUpClass(cls):
)

def test_fleet_vehicle_inspection(self):

self.inspection._onchange_inspection_template_id()

# Existing assertions
self.assertEqual(self.inspection.name, self.inspection_template.name)
self.assertTrue(self.inspection.inspection_line_ids)

# New assertions for sequence
self.assertEqual(len(self.inspection.inspection_line_ids), 2)

# Check if the sequence is correctly copied from the template line
line_1 = self.inspection.inspection_line_ids.filtered(
lambda linei: linei.inspection_item_id == self.item_01
)
self.assertEqual(line_1.sequence, 5)

# Check if the sequence defaults to the item's sequence if not set in the template line
line_2 = self.inspection.inspection_line_ids.filtered(
lambda linei: linei.inspection_item_id == self.item_02
)
self.assertEqual(line_2.sequence, self.item_02.sequence)

0 comments on commit e261302

Please sign in to comment.