cubicweb/server/test/unittest_schemaserial.py
changeset 11215 4e79acdc36a6
parent 11077 09be48c01fa4
child 11269 73ac69970047
equal deleted inserted replaced
11212:3309ddb97059 11215:4e79acdc36a6
   113               'cardinality': u'1*',
   113               'cardinality': u'1*',
   114               'ordernum': 1}),
   114               'ordernum': 1}),
   115             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   115             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   116              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   116              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   117              {'x': None, 'ct': u'RQLConstraint_eid',
   117              {'x': None, 'ct': u'RQLConstraint_eid',
   118               'value': u';O;O final TRUE\n'}),
   118               'value': u'{"expression": "O final TRUE", "mainvars": ["O"], "msg": null}'}),
   119 
   119 
   120             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,'
   120             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,'
   121              'X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,'
   121              'X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,'
   122              'X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   122              'X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   123              {'se': None, 'rt': None, 'oe': None,
   123              {'se': None, 'rt': None, 'oe': None,
   124               'description': u'', 'composite': u'object',
   124               'description': u'', 'composite': u'object',
   125               'ordernum': 1, 'cardinality': u'1*'}),
   125               'ordernum': 1, 'cardinality': u'1*'}),
   126             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   126             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   127              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   127              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   128              {'x': None, 'ct': u'RQLConstraint_eid', 'value': u';O;O final FALSE\n'}),
   128              {'x': None, 'ct': u'RQLConstraint_eid', 'value': u'{"expression": "O final FALSE", "mainvars": ["O"], "msg": null}'}),
   129         ],
   129         ],
   130                              list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)))
   130                              list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)))
   131 
   131 
   132     def test_rschema2rql2(self):
   132     def test_rschema2rql2(self):
   133         self.assertListEqual([
   133         self.assertListEqual([
   234               'cardinality': u'?1'}),
   234               'cardinality': u'?1'}),
   235             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   235             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   236              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   236              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   237              {'x': None,
   237              {'x': None,
   238               'ct': u'SizeConstraint_eid',
   238               'ct': u'SizeConstraint_eid',
   239               'value': u'max=2'}),
   239               'value': u'{"max": 2, "min": null}'}),
   240             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   240             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   241              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   241              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   242              {'x': None,
   242              {'x': None,
   243               'ct': u'StaticVocabularyConstraint_eid',
   243               'ct': u'StaticVocabularyConstraint_eid',
   244               'value': u"u'?1', u'11'"}),
   244               'value': u'["?1", "11"]'}),
   245 
   245 
   246             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   246             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   247              'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
   247              'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
   248              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   248              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   249              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE '
   249              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE '
   261               'cardinality': u'?1'}),
   261               'cardinality': u'?1'}),
   262             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   262             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   263              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   263              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   264              {'x': None,
   264              {'x': None,
   265               'ct': u'SizeConstraint_eid',
   265               'ct': u'SizeConstraint_eid',
   266               'value': u'max=2'}),
   266               'value': u'{"max": 2, "min": null}'}),
   267             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   267             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   268              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   268              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   269              {'x': None,
   269              {'x': None,
   270               'ct': u'StaticVocabularyConstraint_eid',
   270               'ct': u'StaticVocabularyConstraint_eid',
   271               'value': (u"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', "
   271               "value": (u'["?*", "1*", "+*", "**", "?+", "1+", "++", "*+", "?1", '
   272                         "u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'")})],
   272                         u'"11", "+1", "*1", "??", "1?", "+?", "*?"]')})],
   273               list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
   273               list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
   274 
   274 
   275     def test_rschema2rql_custom_type(self):
   275     def test_rschema2rql_custom_type(self):
   276         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
   276         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
   277                      'X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,'
   277                      'X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,'
   332               'value': u'None',
   332               'value': u'None',
   333               'ct': 'FormatConstraint_eid'}),
   333               'ct': 'FormatConstraint_eid'}),
   334             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   334             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X '
   335              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   335              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   336              {'x': None,
   336              {'x': None,
   337               'value': u'max=50',
   337               'value': u'{"max": 50, "min": null}',
   338               'ct': 'SizeConstraint_eid'})],
   338               'ct': 'SizeConstraint_eid'})],
   339                              list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')],
   339                              list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')],
   340                                            cstrtypemap)))
   340                                            cstrtypemap)))
   341 
   341 
   342     def test_updateeschema2rql1(self):
   342     def test_updateeschema2rql1(self):