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.

52 lines
1.7 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. self.users = self.env["res.users"].search([])
  12. def test_action_result(self):
  13. result = self.action_server.with_context(
  14. active_model="res.users",
  15. active_ids=self.users.ids).run()
  16. self.assertEqual(result.get("id", False), False)
  17. self.assertEqual(
  18. 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(
  27. line_qty - 1,
  28. len(self.action_server.navigate_line_ids)
  29. )
  30. def test_action_navigate_with_action(self):
  31. self.action_server.navigate_action_id = self.env.ref(
  32. "base.action_partner_category_form")
  33. result = self.action_server.with_context(
  34. active_model="res.users",
  35. active_ids=self.users.ids).run()
  36. self.assertEqual(
  37. result.get("id", False),
  38. self.env.ref("base.action_partner_category_form").id,
  39. )