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.

42 lines
1.5 KiB

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