From 40691db7e68d054e62133a9fa2c65455840cb0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 13 Jun 2023 08:56:52 +0200 Subject: [PATCH] Use message for constraint on tests models --- trytond/trytond/tests/field_one2one.py | 4 ++-- trytond/trytond/tests/message.xml | 15 +++++++++++++++ trytond/trytond/tests/modelsql.py | 7 +++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/trytond/trytond/tests/field_one2one.py b/trytond/trytond/tests/field_one2one.py index 963bfd7e11..981fc9e1c9 100644 --- a/trytond/trytond/tests/field_one2one.py +++ b/trytond/trytond/tests/field_one2one.py @@ -30,9 +30,9 @@ class One2OneRelation(ModelSQL): table = cls.__table__() cls._sql_constraints += [ ('origin_unique', Unique(table, table.origin), - 'Origin must be unique'), + 'tests.msg_one2one_relation_origin_unique'), ('target_unique', Unique(table, table.target), - 'Target must be unique'), + 'tests.msg_one2one_relation_target_unique'), ] diff --git a/trytond/trytond/tests/message.xml b/trytond/trytond/tests/message.xml index 3b5be09441..ad8405e283 100644 --- a/trytond/trytond/tests/message.xml +++ b/trytond/trytond/tests/message.xml @@ -6,5 +6,20 @@ this repository contains the full copyright notices and license terms. --> Message + + Value must be greater than 42. + + + Value must be unique. + + + Value must be unique. + + + Origin must be unique. + + + Target must be unique. + diff --git a/trytond/trytond/tests/modelsql.py b/trytond/trytond/tests/modelsql.py index dfda3a7fc1..8e6506af4b 100644 --- a/trytond/trytond/tests/modelsql.py +++ b/trytond/trytond/tests/modelsql.py @@ -184,8 +184,7 @@ class ModelCheck(ModelSQL): super(ModelCheck, cls).__setup__() t = cls.__table__() cls._sql_constraints = [ - ('check', Check(t, (t.value > 42)), - "Value must be greater than 42."), + ('check', Check(t, (t.value > 42)), 'tests.msg_modelsql_check'), ] @@ -199,7 +198,7 @@ class ModelUnique(ModelSQL): super(ModelUnique, cls).__setup__() t = cls.__table__() cls._sql_constraints = [ - ('unique', Unique(t, t.value), "Value must be unique."), + ('unique', Unique(t, t.value), 'tests.msg_modelsql_unique'), ] @@ -220,7 +219,7 @@ class ModelExclude(ModelSQL): cls._sql_constraints = [ ('exclude', Exclude(t, (t.value, Equal), where=t.condition == Literal(True)), - "Value must be unique."), + 'tests.msg_modelsql_exclude'), ]