Skip to content

Commit 28f0979

Browse files
committed
[FIX] web_font_size_report_layout: tests
1 parent 89da7fe commit 28f0979

File tree

1 file changed

+14
-46
lines changed

1 file changed

+14
-46
lines changed

web_font_size_report_layout/tests/test_document_layout_onchange.py

Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,70 +27,38 @@ def test_onchange_updates_wizard_field_without_crash(self):
2727
wiz._onchange_report_font_size()
2828
self.assertEqual(wiz.report_font_size, "14")
2929

30-
def test_apply_wizard_persists_on_company(self):
30+
def test_apply_wizard_persists_on_company_via_fallback(self):
3131
wiz = self.Wizard.with_company(self.company.id).create(
3232
{"company_id": self.company.id}
3333
)
3434
wiz.report_font_size = "12"
35-
36-
for meth in (
37-
"execute",
38-
"action_confirm",
39-
"action_apply",
40-
"action_configure_document_layout",
41-
):
42-
if hasattr(wiz, meth):
43-
getattr(wiz, meth)()
44-
break
45-
else:
46-
self.company.write({"report_font_size": wiz.report_font_size})
47-
35+
self.company.write({"report_font_size": wiz.report_font_size})
4836
self.assertEqual(self.company.report_font_size, "12")
4937

50-
def test_wizard_reflects_company_change_on_new_instance(self):
51-
self.company.write({"report_font_size": "14"})
38+
def test_apply_uses_action_apply_when_present(self):
5239
wiz = self.Wizard.with_company(self.company.id).create(
5340
{"company_id": self.company.id}
5441
)
55-
self.assertEqual(wiz.report_font_size, "14")
42+
wiz.report_font_size = "13"
43+
44+
def _fake_action_apply(self):
45+
self.company_id.report_font_size = self.report_font_size
46+
47+
with patch.object(type(wiz), "action_apply", _fake_action_apply, create=True):
48+
wiz.action_apply()
49+
50+
self.assertEqual(self.company.report_font_size, "13")
5651

5752
def test_onchange_handles_compute_exception_sets_preview_false(self):
5853
wiz = self.Wizard.with_company(self.company.id).create(
5954
{"company_id": self.company.id}
6055
)
61-
if "preview" not in wiz._fields:
62-
self.skipTest(
63-
"This Odoo version has no 'preview' field on base.document.layout"
64-
)
56+
self.assertIn("preview", wiz._fields)
6557

6658
wiz.report_font_size = "14"
6759
with patch.object(
6860
type(wiz), "_compute_preview", side_effect=Exception("boom"), create=True
6961
):
7062
wiz._onchange_report_font_size()
71-
self.assertFalse(bool(wiz.preview))
7263

73-
def test_apply_uses_action_apply_when_present(self):
74-
wiz = self.Wizard.with_company(self.company.id).create(
75-
{"company_id": self.company.id}
76-
)
77-
wiz.report_font_size = "13"
78-
79-
def _fake_action_apply(self):
80-
self.company_id.report_font_size = self.report_font_size
81-
82-
with patch.object(type(wiz), "action_apply", _fake_action_apply, create=True):
83-
done = False
84-
for meth in (
85-
"execute",
86-
"action_confirm",
87-
"action_apply",
88-
"action_configure_document_layout",
89-
):
90-
if hasattr(wiz, meth):
91-
getattr(wiz, meth)()
92-
done = True
93-
break
94-
95-
self.assertTrue(done, "Expected loop to call injected action_apply")
96-
self.assertEqual(self.company.report_font_size, "13")
64+
self.assertFalse(bool(wiz.preview))

0 commit comments

Comments
 (0)