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.

47 lines
1.7 KiB

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