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.

49 lines
1.9 KiB

  1. # Copyright 2016 LasLabs Inc.
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
  3. from odoo.tests.common import TransactionCase
  4. class TestBaseKanbanStage(TransactionCase):
  5. def test_default_res_model_id_no_params(self):
  6. """It should return empty ir.model Recordset if no params in context"""
  7. test_stage = self.env['base.kanban.stage'].with_context({})
  8. res_model_id = test_stage._default_res_model_id()
  9. self.assertFalse(res_model_id)
  10. self.assertEqual(res_model_id._name, 'ir.model')
  11. def test_default_res_model_id_no_action(self):
  12. """It should return empty ir.model Recordset if no action in params"""
  13. test_stage = self.env['base.kanban.stage'].with_context(params={})
  14. res_model_id = test_stage._default_res_model_id()
  15. self.assertFalse(res_model_id)
  16. self.assertEqual(res_model_id._name, 'ir.model')
  17. def test_default_res_model_id_info_in_context(self):
  18. """It should return correct ir.model record if info in context"""
  19. test_action = self.env['ir.actions.act_window'].create({
  20. 'name': 'Test Action',
  21. 'res_model': 'res.users',
  22. })
  23. test_stage = self.env['base.kanban.stage'].with_context(
  24. params={'action': test_action.id},
  25. )
  26. self.assertEqual(
  27. test_stage._default_res_model_id(),
  28. self.env['ir.model'].search([('model', '=', 'res.users')])
  29. )
  30. def test_default_res_model_id_ignore_self(self):
  31. """It should not return ir.model record corresponding to stage model"""
  32. test_action = self.env['ir.actions.act_window'].create({
  33. 'name': 'Test Action',
  34. 'res_model': 'base.kanban.stage',
  35. })
  36. test_stage = self.env['base.kanban.stage'].with_context(
  37. params={'action': test_action.id},
  38. )
  39. self.assertFalse(test_stage._default_res_model_id())