Commit df5f6089 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

Update to yams 0.44 API

parent ef53a59140e1
......@@ -25,7 +25,7 @@ Requires: %{python}-six >= 1.4.0
Requires: %{python}-logilab-common >= 1.2.2
Requires: %{python}-logilab-mtconverter >= 0.8.0
Requires: %{python}-rql >= 0.34.0
Requires: %{python}-yams >= 0.43.0
Requires: %{python}-yams >= 0.44.0
Requires: %{python}-logilab-database >= 1.15.0
Requires: %{python}-passlib
Requires: %{python}-lxml
......
......@@ -48,7 +48,7 @@ __depends__ = {
'logilab-common': '>= 1.2.2',
'logilab-mtconverter': '>= 0.8.0',
'rql': '>= 0.34.0',
'yams': '>= 0.43.0',
'yams': '>= 0.44.0',
#gettext # for xgettext, msgcat, etc...
# web dependencies
'lxml': '',
......
......@@ -427,5 +427,6 @@ class IUserFriendlyCheckConstraint(IUserFriendlyError):
# constraint between two attributes). This should be the purpose of an api rework at some
# point, we currently rely on the fact that such constraint will provide a dedicated user
# message not relying on the `value` argument
msg, args = constraint.failed_message(key, self.entity.cw_edited.get(rschema.type))
value = self.entity.cw_edited.get(rschema.type)
msg, args = constraint.failed_message(key, value, self.entity)
raise ValidationError(self.entity.eid, {key: msg}, args)
......@@ -274,7 +274,8 @@ class SchemaModificationHooksTC(CubicWebTC):
def test_unique_change(self):
with self.admin_access.repo_cnx() as cnx:
try:
eid = cnx.execute('INSERT CWConstraint X: X cstrtype CT, DEF constrained_by X '
eid = cnx.execute('INSERT CWConstraint X: X cstrtype CT, X value "{}", '
' DEF constrained_by X '
'WHERE CT name "UniqueConstraint", DEF relation_type RT, '
'DEF from_entity E, RT name "name", '
'E name "Workflow"').rows[0][0]
......
......@@ -52,7 +52,7 @@ CREATE TABLE Datetest(
d2 date,
t1 time,
t2 time
, CONSTRAINT cstr67c656afbcbfadd4be34d75656a2521a CHECK(d1 <= CAST(clock_timestamp() AS DATE))
, CONSTRAINT cstrf6a3dad792ba13c2cddcf61a2b737c00 CHECK(d1 <= CAST(clock_timestamp() AS DATE))
);
CREATE TABLE Division(
......@@ -97,7 +97,7 @@ CREATE TABLE Person(
datenaiss date,
test boolean,
salary float
, CONSTRAINT cstrdedefafc86dc831341c33547388c25bb CHECK(promo IN ('bon', 'pasbon'))
, CONSTRAINT cstr151c2116c0c09de13fded0619d5b4aac CHECK(promo IN ('bon', 'pasbon'))
);
CREATE UNIQUE INDEX unique_e6c2d219772dbf1715597f7d9a6b3892 ON Person(nom,prenom);
......@@ -115,7 +115,7 @@ CREATE TABLE Salaried(
datenaiss date,
test boolean,
salary float
, CONSTRAINT cstrb62a1623de9e9b92eb552706b6ce0890 CHECK(promo IN ('bon', 'pasbon'))
, CONSTRAINT cstr069569cf1791dba1a2726197c53aeb44 CHECK(promo IN ('bon', 'pasbon'))
);
CREATE UNIQUE INDEX unique_98da0f9de8588baa8966f0b1a6f850a3 ON Salaried(nom,prenom);
......@@ -130,7 +130,7 @@ CREATE TABLE Societe(
ad3 varchar(128),
cp varchar(12),
ville varchar(32)
, CONSTRAINT cstraf91cb60287eec6d5c1175075edcccc0 CHECK(fax <= tel)
, CONSTRAINT cstra0a1deaa997dcd5f9b83a77654d7c287 CHECK(fax <= tel)
);
CREATE TABLE State(
......@@ -159,8 +159,8 @@ CREATE TABLE pkginfo(
author_email varchar(100) NOT NULL,
mailinglist varchar(100),
debian_handler varchar(6)
, CONSTRAINT cstree063a486aa92d4f721ced56c819f38a CHECK(license IN ('GPL', 'ZPL'))
, CONSTRAINT cstrafb4b6de5d50b5a2eca60b33b7acf59b CHECK(debian_handler IN ('machin', 'bidule'))
, CONSTRAINT cstrbffed5ce7306d65a0db51182febd4a7b CHECK(license IN ('GPL', 'ZPL'))
, CONSTRAINT cstr2238b33d09bf7c441e0888be354c2444 CHECK(debian_handler IN ('machin', 'bidule'))
);
......
......@@ -235,12 +235,12 @@ class Schema2RQLTC(TestCase):
'WHERE CT eid %(ct)s, EDEF eid %(x)s',
{'x': None,
'ct': u'SizeConstraint_eid',
'value': u'{"max": 2, "min": null}'}),
'value': u'{"max": 2, "min": null, "msg": null}'}),
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
'WHERE CT eid %(ct)s, EDEF eid %(x)s',
{'x': None,
'ct': u'StaticVocabularyConstraint_eid',
'value': u'["?1", "11"]'}),
'value': u'{"msg": null, "values": ["?1", "11"]}'}),
('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
......@@ -262,13 +262,13 @@ class Schema2RQLTC(TestCase):
'WHERE CT eid %(ct)s, EDEF eid %(x)s',
{'x': None,
'ct': u'SizeConstraint_eid',
'value': u'{"max": 2, "min": null}'}),
'value': u'{"max": 2, "min": null, "msg": null}'}),
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
'WHERE CT eid %(ct)s, EDEF eid %(x)s',
{'x': None,
'ct': u'StaticVocabularyConstraint_eid',
"value": (u'["?*", "1*", "+*", "**", "?+", "1+", "++", "*+", "?1", '
u'"11", "+1", "*1", "??", "1?", "+?", "*?"]')})],
"value": (u'{"msg": null, "values": ["?*", "1*", "+*", "**", "?+", "1+", "++", "*+", "?1", '
u'"11", "+1", "*1", "??", "1?", "+?", "*?"]}')})],
list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
def test_rschema2rql_custom_type(self):
......@@ -328,12 +328,13 @@ class Schema2RQLTC(TestCase):
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
'WHERE CT eid %(ct)s, EDEF eid %(x)s',
{'x': None,
'value': u'None',
'value': u'{"msg": null, "values": ["text/rest", "text/markdown", '
'"text/html", "text/plain"]}',
'ct': 'FormatConstraint_eid'}),
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
'WHERE CT eid %(ct)s, EDEF eid %(x)s',
{'x': None,
'value': u'{"max": 50, "min": null}',
'value': u'{"max": 50, "min": null, "msg": null}',
'ct': 'SizeConstraint_eid'})],
list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')],
cstrtypemap)))
......
......@@ -16,7 +16,7 @@ Build-Depends:
python-markdown,
python-tz,
python-rql (>= 0.34.0),
python-yams (>= 0.43.0),
python-yams (>= 0.44.0),
python-lxml,
Standards-Version: 3.9.1
Homepage: https://www.cubicweb.org
......
pytest
hg+http://hg.logilab.org/master/yams#egg=yams
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment