Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
RPSJR committed Oct 28, 2024
1 parent 798d924 commit f98fc5d
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def setUpClass(cls):
)

def test_fleet_vehicle_inspection(self):
# --- Test with an inspection template ---
self.inspection._onchange_inspection_template_id()

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

Expand All @@ -79,12 +79,25 @@ def test_fleet_vehicle_inspection(self):
# Trigger the onchange method again
self.inspection._onchange_inspection_template_id()

# 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
)
# --- Assert the new sequence ---
self.assertEqual(line_1.sequence, 11)

# --- Test without an inspection template ---
self.inspection.inspection_template_id = False # Remove the template

# Trigger the onchange method again
self.inspection._onchange_inspection_template_id()

# Assert that the name and note are not changed
self.assertEqual(self.inspection.name, self.inspection_template_02.name)
# (remains the same as the previous template)
self.assertNotEqual(self.inspection.name, self.inspection_template_01.name)

# Assert that the inspection lines are NOT removed
self.assertTrue(self.inspection.inspection_line_ids)
self.assertEqual(len(self.inspection.inspection_line_ids), 2)

0 comments on commit f98fc5d

Please sign in to comment.