|
@ -180,6 +180,42 @@ class TestModuleAfterInstall(TransactionCase): |
|
|
finally: |
|
|
finally: |
|
|
Bmu._revert_method('upgrade_module') |
|
|
Bmu._revert_method('upgrade_module') |
|
|
|
|
|
|
|
|
|
|
|
def test_incomplete_upgrade_no_checkusm(self): |
|
|
|
|
|
Imm = self.env['ir.module.module'] |
|
|
|
|
|
Bmu = self.env['base.module.upgrade'] |
|
|
|
|
|
|
|
|
|
|
|
installed_modules = Imm.search( |
|
|
|
|
|
[('state', '=', 'installed')]) |
|
|
|
|
|
# change the checksum of 'base' |
|
|
|
|
|
Imm._save_installed_checksums() |
|
|
|
|
|
saved_checksums = Imm._get_saved_checksums() |
|
|
|
|
|
|
|
|
|
|
|
Imm._save_checksums(saved_checksums) |
|
|
|
|
|
self.base_module.write({'state': 'to upgrade'}) |
|
|
|
|
|
|
|
|
|
|
|
def upgrade_module_mock(self_model): |
|
|
|
|
|
upgrade_module_mock.call_count += 1 |
|
|
|
|
|
# since we are upgrading base, all installed module |
|
|
|
|
|
# must have been marked to upgrade at this stage |
|
|
|
|
|
self.assertEqual(self.base_module.state, 'to upgrade') |
|
|
|
|
|
self.assertEqual(self.own_module.state, 'installed') |
|
|
|
|
|
installed_modules.write({'state': 'installed'}) |
|
|
|
|
|
|
|
|
|
|
|
upgrade_module_mock.call_count = 0 |
|
|
|
|
|
|
|
|
|
|
|
# upgrade_changed_checksum commits, so mock that |
|
|
|
|
|
with mock.patch.object(self.env.cr, 'commit'): |
|
|
|
|
|
|
|
|
|
|
|
# we simulate an install by setting module states |
|
|
|
|
|
Bmu._patch_method('upgrade_module', |
|
|
|
|
|
upgrade_module_mock) |
|
|
|
|
|
# got just other modules to_upgrade and no checksum ones |
|
|
|
|
|
try: |
|
|
|
|
|
Imm.upgrade_changed_checksum() |
|
|
|
|
|
self.assertEqual(upgrade_module_mock.call_count, 1) |
|
|
|
|
|
finally: |
|
|
|
|
|
Bmu._revert_method('upgrade_module') |
|
|
|
|
|
|
|
|
def test_nothing_to_upgrade(self): |
|
|
def test_nothing_to_upgrade(self): |
|
|
Imm = self.env['ir.module.module'] |
|
|
Imm = self.env['ir.module.module'] |
|
|
Bmu = self.env['base.module.upgrade'] |
|
|
Bmu = self.env['base.module.upgrade'] |
|
|