Skip to content

Commit be146f9

Browse files
committed
[IMP] add tests for openupgrade_framework
1 parent 395c02b commit be146f9

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import test_openupgrade_framework
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from odoo.tests.common import TransactionCase
2+
from odoo.tools.misc import mute_logger
3+
4+
from odoo.addons.base.models.ir_model import MODULE_UNINSTALL_FLAG
5+
6+
7+
class TestOpenupgradeFramework(TransactionCase):
8+
def test_01_delete_undeletable_record(self):
9+
"""
10+
Test that Odoo doesn't crash when deleting records that can't be deleted
11+
during module upgrade
12+
"""
13+
with (
14+
mute_logger("odoo.sql_db"),
15+
self.assertLogs(
16+
"odoo.addons.openupgrade_framework.odoo_patch.odoo.orm.models"
17+
),
18+
):
19+
self.env.ref("base.partner_admin").with_context(
20+
**{MODULE_UNINSTALL_FLAG: True}
21+
).unlink()
22+
23+
def test_02_invalid_view(self):
24+
"""
25+
Test that we patch away fatal view errors and log the problem
26+
"""
27+
with self.assertLogs(
28+
"odoo.addons.openupgrade_framework.odoo_patch.odoo.addons.base.models.ir_ui_view"
29+
):
30+
self.env["ir.ui.view"].create(
31+
{
32+
"model": "res.partner",
33+
"arch": '<form><field name="nonexisting_field" /></form>',
34+
}
35+
)

0 commit comments

Comments
 (0)