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.

46 lines
1.7 KiB

7 years ago
7 years ago
7 years ago
  1. # Copyright 2017 LasLabs Inc.
  2. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  3. import mock
  4. from odoo.modules import get_module_path
  5. from odoo.modules.registry import Registry
  6. from odoo.tests.common import TransactionCase
  7. from ..models.module_deprecated import PARAM_DEPRECATED
  8. class TestModuleUpgrade(TransactionCase):
  9. def setUp(self):
  10. super(TestModuleUpgrade, self).setUp()
  11. module_name = 'module_auto_update'
  12. self.env["ir.config_parameter"].set_param(PARAM_DEPRECATED, "1")
  13. self.own_module = self.env['ir.module.module'].search([
  14. ('name', '=', module_name),
  15. ])
  16. self.own_dir_path = get_module_path(module_name)
  17. def test_upgrade_module_cancel(self):
  18. """It should preserve checksum_installed when cancelling upgrades"""
  19. self.own_module.write({'state': 'to upgrade'})
  20. self.own_module.checksum_installed = 'test'
  21. self.env['base.module.upgrade'].upgrade_module_cancel()
  22. self.assertEqual(
  23. self.own_module.checksum_installed, 'test',
  24. 'Upgrade cancellation does not preserve checksum_installed',
  25. )
  26. @mock.patch.object(Registry, 'new')
  27. def test_upgrade_module(self, new_mock):
  28. """Calls get_module_list when upgrading in api.model mode"""
  29. get_module_list_mock = mock.MagicMock()
  30. try:
  31. self.env['base.module.upgrade']._patch_method(
  32. 'get_module_list',
  33. get_module_list_mock,
  34. )
  35. self.env['base.module.upgrade'].upgrade_module()
  36. get_module_list_mock.assert_called_once_with()
  37. finally:
  38. self.env['base.module.upgrade']._revert_method('get_module_list')