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.

40 lines
1.7 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 Therp BV <https://therp.nl>.
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  4. from . import common
  5. from ..tablib import Tab
  6. class TestTab(common.TestCommon):
  7. def test_create_page(self):
  8. self.assertTrue(bool(self.tab_board))
  9. tab_obj = Tab(self.tab_board)
  10. page = tab_obj.create_page()
  11. # And we should have a field for (amongst others) selection_type_id.
  12. field = page.xpath('//field[@name="type_selection_id"]')
  13. self.assertTrue(field, 'Field selection_type_id not in page.')
  14. def test_visibility(self):
  15. """Tab positions should be shown for functionaries, but not others."""
  16. self.assertTrue(bool(self.tab_positions))
  17. self.assertTrue(bool(self.partner_important_person))
  18. self.assertTrue(bool(self.partner_common_person))
  19. tab_obj = Tab(self.tab_positions)
  20. self.assertTrue(
  21. tab_obj.compute_visibility(self.partner_important_person),
  22. 'Positions tab should be visible for functionary.')
  23. self.assertFalse(
  24. tab_obj.compute_visibility(self.partner_common_person),
  25. 'Positions tab should not be visible for non-functionary.')
  26. # Tab for departments should only be visible for main partner
  27. self.assertTrue(bool(self.tab_departments))
  28. self.assertTrue(bool(self.partner_big_company))
  29. tab_obj = Tab(self.tab_departments)
  30. self.assertTrue(
  31. tab_obj.compute_visibility(self.env.ref('base.main_partner')),
  32. 'Department tab should be visible for main partner.')
  33. self.assertFalse(
  34. tab_obj.compute_visibility(self.partner_big_company),
  35. 'Department tab should not be visible for other partners.')