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.

43 lines
1.6 KiB

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. class TestModuleUpgrade(TransactionCase):
  8. def setUp(self):
  9. super(TestModuleUpgrade, self).setUp()
  10. module_name = 'module_auto_update'
  11. self.own_module = self.env['ir.module.module'].search([
  12. ('name', '=', module_name),
  13. ])
  14. self.own_dir_path = get_module_path(module_name)
  15. def test_upgrade_module_cancel(self):
  16. """It should preserve checksum_installed when cancelling upgrades"""
  17. self.own_module.write({'state': 'to upgrade'})
  18. self.own_module.checksum_installed = 'test'
  19. self.env['base.module.upgrade'].upgrade_module_cancel()
  20. self.assertEqual(
  21. self.own_module.checksum_installed, 'test',
  22. 'Upgrade cancellation does not preserve checksum_installed',
  23. )
  24. @mock.patch.object(Registry, 'new')
  25. def test_upgrade_module(self, new_mock):
  26. """Calls get_module_list when upgrading in api.model mode"""
  27. get_module_list_mock = mock.MagicMock()
  28. try:
  29. self.env['base.module.upgrade']._patch_method(
  30. 'get_module_list',
  31. get_module_list_mock,
  32. )
  33. self.env['base.module.upgrade'].upgrade_module()
  34. get_module_list_mock.assert_called_once_with()
  35. finally:
  36. self.env['base.module.upgrade']._revert_method('get_module_list')