Commit 67e4b95d authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

improved checks for required attributes

parent e7132e61cd68
ChangeLog for yams
------------------
-- 0.10.0
--
* introduced Interval
* dropped the schema_view module
* new has_unique_values method on EntitySchema instance checking if a
subject relation should be unique
* improved required attributes' checks
2007-05-14 -- 0.10.0
* automatically sets maxsize only for String attributes (fix #3272)
......
......@@ -441,7 +441,9 @@ class EntitySchema(ERSchema):
# on edition, missing attribute is considered as no changes
continue
# skip other constraint if value is None and None is allowed
if value is None and not required:
if value is None:
if required:
errors[rschema] = _('required attribute')
continue
if not aschema.check_value(value):
errors[rschema] = _('incorrect value %r for type %s') % (value,
......
......@@ -62,6 +62,8 @@ class BaseSchemaTC(TestCase):
enote.set_rproperty('type', 'constraints',
[StaticVocabularyConstraint((u'bon', u'pasbon',
u'bof', u'peux mieux faire'))])
enote.set_rproperty('date', 'cardinality', '11')
eaffaire.set_rproperty('sujet', 'constraints', [SizeConstraint(128)])
eaffaire.set_rproperty('ref', 'constraints', [SizeConstraint(12)])
eperson.set_rproperty('nom', 'constraints', [SizeConstraint(20, 10)])
......@@ -103,8 +105,11 @@ ATTRIBUTE_BAD_VALUES = (
## ('Affaire', [('starton', 'midi')]),
('Note', [('type', ['bof', 'peux mieux faire']),
('type', 'bof, je suis pas unicode, alors...')]),
('type', 'bof, je suis pas unicode, alors...'),
('date', None),
]),
)
ATTRIBUTE_GOOD_VALUES = (
('Person', [('nom', u'>10 mais < 20 '), ('sexe', 0.5),
('promo', u'bon'),
......@@ -323,7 +328,7 @@ class SchemaTC(BaseSchemaTC):
"""test base schema methods
"""
all_types = ['Affaire', 'Boolean', 'Bytes', 'Date', 'Datetime',
'Float', 'Int', 'Note', 'Password',
'Float', 'Int', 'Interval', 'Note', 'Password',
'Person', 'Societe', 'String', 'Time']
types = schema.entities()
types.sort()
......
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