summaryrefslogtreecommitdiff
path: root/odoo/addons/test_rpc
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-07-03 19:20:31 +0200
committerChristophe Simonis <chs@odoo.com>2019-07-03 19:20:31 +0200
commit24b677a3597beaf0e0509fd09d8f71c7803d8f09 (patch)
tree1fd1c3b20b4084506747eae92bd25a26d232edf6 /odoo/addons/test_rpc
parentacbdd526e64739914f864942d846b2c29008b362 (diff)
[FIX] test_rpc: more robust tests
- mute logger to avoid logging bad queries - enforce fields strings These changes will forbid tests to fail in following versions.
Diffstat (limited to 'odoo/addons/test_rpc')
-rw-r--r--odoo/addons/test_rpc/models.py4
-rw-r--r--odoo/addons/test_rpc/tests/test_error.py12
2 files changed, 10 insertions, 6 deletions
diff --git a/odoo/addons/test_rpc/models.py b/odoo/addons/test_rpc/models.py
index 701b4b10ca8..2d547a9947e 100644
--- a/odoo/addons/test_rpc/models.py
+++ b/odoo/addons/test_rpc/models.py
@@ -9,8 +9,8 @@ class ModelA(models.Model):
_description = "Model A"
name = fields.Char(required=True)
- field_b1 = fields.Many2one("test_rpc.model_b", required=True)
- field_b2 = fields.Many2one("test_rpc.model_b", ondelete="restrict")
+ field_b1 = fields.Many2one("test_rpc.model_b", string="required field", required=True)
+ field_b2 = fields.Many2one("test_rpc.model_b", string="restricted field", ondelete="restrict")
class ModelB(models.Model):
diff --git a/odoo/addons/test_rpc/tests/test_error.py b/odoo/addons/test_rpc/tests/test_error.py
index 3266b97a699..6896b1f180d 100644
--- a/odoo/addons/test_rpc/tests/test_error.py
+++ b/odoo/addons/test_rpc/tests/test_error.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from odoo.tests import common
+from odoo.tools.misc import mute_logger
class TestError(common.HttpCase):
@@ -15,7 +16,8 @@ class TestError(common.HttpCase):
""" Create: mandatory field not provided """
self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {"name": "B1"})
try:
- self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {})
+ with mute_logger("odoo.sql_db"):
+ self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "create", {})
raise
except Exception as e:
self.assertIn("The operation cannot be completed:", e.faultString)
@@ -38,7 +40,8 @@ class TestError(common.HttpCase):
# FORWARD-PORT: in master, `required=True` implies `ondelete="restrict"`
# => the message should be the same than 'Unlink b2' case.
try:
- self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b1)
+ with mute_logger("odoo.sql_db"):
+ self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b1)
raise
except Exception as e:
self.assertIn("The operation cannot be completed:", e.faultString)
@@ -47,11 +50,12 @@ class TestError(common.HttpCase):
"Delete: another model requires the record being deleted. If possible, archive it instead.",
e.faultString,
)
- self.assertIn("Model: Model A (test_rpc.model_a), Field: Field b1 (field_b1)", e.faultString)
+ self.assertIn("Model: Model A (test_rpc.model_a), Field: required field (field_b1)", e.faultString)
# Unlink b2 => ON DELETE RESTRICT constraint raises
try:
- self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b2)
+ with mute_logger("odoo.sql_db"):
+ self.o.execute(self.db_name, 1, "admin", "test_rpc.model_b", "unlink", b2)
raise
except Exception as e:
self.assertIn("The operation cannot be completed:", e.faultString)