You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.6 KiB

  1. # Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
  2. # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from odoo.tests.common import TransactionCase
  5. from odoo.tools.safe_eval import safe_eval
  6. class TestModule(TransactionCase):
  7. def setUp(self):
  8. super().setUp()
  9. self.action_server = self.env.ref(
  10. "server_action_navigate.navigate_partner_2_tags"
  11. )
  12. self.users = self.env["res.users"].search([])
  13. def test_action_result(self):
  14. result = self.action_server.with_context(
  15. active_model="res.users", active_ids=self.users.ids
  16. ).run()
  17. self.assertEqual(result.get("id", False), False)
  18. self.assertEqual(result.get("res_model", False), "res.partner.category")
  19. self.assertEqual(
  20. safe_eval(result.get("domain", [])),
  21. [("id", "in", self.users.mapped("partner_id.category_id").ids)],
  22. )
  23. def test_delete_last_line(self):
  24. line_qty = len(self.action_server.navigate_line_ids)
  25. self.action_server.delete_last_line()
  26. self.assertEqual(line_qty - 1, len(self.action_server.navigate_line_ids))
  27. def test_action_navigate_with_action(self):
  28. self.action_server.navigate_action_id = self.env.ref(
  29. "base.action_partner_category_form"
  30. )
  31. result = self.action_server.with_context(
  32. active_model="res.users", active_ids=self.users.ids
  33. ).run()
  34. self.assertEqual(
  35. result.get("id", False),
  36. self.env.ref("base.action_partner_category_form").id,
  37. )