Skip to content

Commit

Permalink
[IMP] maintenance_request_repair: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kaynnan committed Mar 21, 2023
1 parent 9cdc66f commit 88f0519
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions maintenance_request_repair/tests/test_repair_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ def setUp(self):
def test_compute_maintenance_request_count(self):

self.repair_order._compute_maintenance_request_count()
assert self.repair_order.maintenance_request_count == 2
self.assertEqual(
self.repair_order.maintenance_request_count,
len(self.repair_order.maintenance_request_ids),
"Computed maintenance request count is incorrect",
)

def test_action_view_maintenance_request(self):

Expand All @@ -64,14 +68,38 @@ def test_action_view_maintenance_request(self):
self.maintenance_request_ids = self.repair_order.mapped(
"maintenance_request_ids"
)

self.repair_order.maintenance_request_ids = False
self.repair_order._compute_maintenance_request_count()
self.action_result = self.repair_order.action_view_maintenance_request()
self.assertTrue("domain" in self.action_result)

self.repair_order.maintenance_request_ids = self.request1
self.repair_order._compute_maintenance_request_count()
self.action_result = self.repair_order.action_view_maintenance_request()
self.assertTrue("views" in self.action_result)
self.assertTrue("res_id" in self.action_result)

def test_form_view(self):
self.maintenance_request = self.env["maintenance.request"].create(
{
"name": "Test Request",
}
)
self.maintenance_request_ids = self.env["maintenance.request"].search(
[("name", "=", "Test Request")]
)

self.res = self.env.ref("maintenance.hr_equipment_request_view_form", False)
self.form_view = [("form", self.res.id)] if self.res else []
self.result = {}
if "views" in self.result:
self.result["views"] = self.form_view + [
(state, view) for state, view in self.result["views"] if view != "form"
]
else:
self.result["views"] = self.form_view
self.result["res_id"] = self.maintenance_request_ids.id

self.assertEqual(
self.result["views"],
[("form", self.env.ref("maintenance.hr_equipment_request_view_form").id)],
)

0 comments on commit 88f0519

Please sign in to comment.