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.

71 lines
2.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # (c) 2015 ACSONE SA/NV, Dhinesh D
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp.tests import common
  5. class TestIrConfigParameter(common.TransactionCase):
  6. def setUp(self):
  7. super(TestIrConfigParameter, self).setUp()
  8. self.db = self.env.cr.dbname
  9. self.param_obj = self.env['ir.config_parameter']
  10. self.data_obj = self.env['ir.model.data']
  11. self.delay = self.env.ref(
  12. 'auth_session_timeout.inactive_session_time_out_delay')
  13. def test_check_session_params(self):
  14. delay, urls = self.param_obj.get_session_parameters(self.db)
  15. self.assertEqual(delay, int(self.delay.value))
  16. self.assertIsInstance(delay, int)
  17. self.assertIsInstance(urls, list)
  18. def test_check_session_param_delay(self):
  19. delay = self.param_obj._auth_timeout_get_parameter_delay()
  20. self.assertEqual(delay, int(self.delay.value))
  21. self.assertIsInstance(delay, int)
  22. def test_check_session_param_urls(self):
  23. urls = self.param_obj._auth_timeout_get_parameter_ignoredurls()
  24. self.assertIsInstance(urls, list)
  25. class TestIrConfigParameterCaching(common.TransactionCase):
  26. def setUp(self):
  27. super(TestIrConfigParameterCaching, self).setUp()
  28. self.db = self.env.cr.dbname
  29. self.param_obj = self.env['ir.config_parameter']
  30. self.get_param_called = False
  31. test = self
  32. def get_param(*args, **kwargs):
  33. test.get_param_called = True
  34. return orig_get_param(args[3], args[4])
  35. orig_get_param = self.param_obj.get_param
  36. self.param_obj._patch_method(
  37. 'get_param',
  38. get_param)
  39. def tearDown(self):
  40. super(TestIrConfigParameterCaching, self).tearDown()
  41. self.param_obj._revert_method('get_param')
  42. def test_check_param_cache_working(self):
  43. self.get_param_called = False
  44. delay, urls = self.param_obj.get_session_parameters(self.db)
  45. self.assertTrue(self.get_param_called)
  46. self.get_param_called = False
  47. delay, urls = self.param_obj.get_session_parameters(self.db)
  48. self.assertFalse(self.get_param_called)
  49. def test_check_param_writes_clear_cache(self):
  50. self.get_param_called = False
  51. delay, urls = self.param_obj.get_session_parameters(self.db)
  52. self.assertTrue(self.get_param_called)
  53. self.get_param_called = False
  54. self.param_obj.set_param('inactive_session_time_out_delay', 7201)
  55. delay, urls = self.param_obj.get_session_parameters(self.db)
  56. self.assertTrue(self.get_param_called)