Skip to content

Commit 37a78bc

Browse files
committed
[FIX] update_record_from_xml test
Now that the `update_record_from_xml` function raise an exception when a records definition cannot be found, the strategy used to test the `from_module` argument of the function doesn't work anymore. Change strategy and test it actually do the job instead. Part-of: #36
1 parent ce74d4a commit 37a78bc

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/base/tests/test_util.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -811,28 +811,29 @@ def test_update_record_translations_from_xml(self):
811811

812812
def test_update_record_from_xml__from_module(self):
813813
cr = self.env.cr
814-
if not util.module_installed(cr, "web"):
815-
self.skip()
814+
if not util.module_installed(cr, "mail"):
815+
self.skipTest("module `mail` not installed")
816816

817-
layout = self.env.ref("web.report_layout")
818-
new_name = str(uuid.uuid4())
817+
xmlid = "base.action_attachment"
818+
action = self.env.ref(xmlid)
819+
new_help = "<p>test_update_record_from_xml__from_module</p>"
819820

820-
layout.write({"name": new_name})
821-
util.flush(layout)
822-
util.invalidate(layout)
821+
action.write({"help": new_help})
822+
util.flush(action)
823+
util.invalidate(action)
823824

824-
# the record `base.report_layout` does not exists, so we must pass the `force_create`.
825-
# we only test that it won't update `web.report_layout`.
826-
util.update_record_from_xml(cr, "base.report_layout", from_module="web", force_create=True)
827-
util.invalidate(layout)
825+
util.update_record_from_xml(cr, xmlid, from_module="mail")
826+
util.invalidate(action)
828827

829-
# web.layout should NOT have been updated
830-
self.assertEqual(layout.name, new_name)
828+
self.assertNotEqual(action.help, new_help)
829+
# the `mail` module overwrite the record to remove the second paragraphe of the help message.
830+
# ensure it actually update the record from the `mail` module.
831+
self.assertEqual(action.help.count("</p>"), 1)
831832

832833
def test_update_record_from_xml_bad_match(self):
833834
cr = self.env.cr
834835
if not util.module_installed(cr, "web"):
835-
self.skip()
836+
self.skipTest("module `web` not installed")
836837

837838
xmlid = "web.login"
838839
util.update_record_from_xml(cr, xmlid)

0 commit comments

Comments
 (0)