server/test/unittest_schemaserial.py
changeset 9965 a8769b752299
parent 9956 19a683a0047c
child 9968 50f046bf0e50
equal deleted inserted replaced
9964:f4a3ee05cf9d 9965:a8769b752299
   220               'final': True,
   220               'final': True,
   221               'fulltext_container': None,
   221               'fulltext_container': None,
   222               'inlined': False}),
   222               'inlined': False}),
   223 
   223 
   224             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   224             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   225              'X description %(description)s,X fulltextindexed %(fulltextindexed)s,'
   225              'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
   226              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   226              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   227              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
   227              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
   228              'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   228              'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   229              {'se': None,
   229              {'se': None,
   230               'rt': None,
   230               'rt': None,
   233               'internationalizable': True,
   233               'internationalizable': True,
   234               'fulltextindexed': False,
   234               'fulltextindexed': False,
   235               'ordernum': 5,
   235               'ordernum': 5,
   236               'defaultval': None,
   236               'defaultval': None,
   237               'indexed': False,
   237               'indexed': False,
       
   238               'formula': None,
   238               'cardinality': u'?1'}),
   239               'cardinality': u'?1'}),
   239             ('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 '
   240              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   241              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   241              {'x': None,
   242              {'x': None,
   242               'ct': u'SizeConstraint_eid',
   243               'ct': u'SizeConstraint_eid',
   246              {'x': None,
   247              {'x': None,
   247               'ct': u'StaticVocabularyConstraint_eid',
   248               'ct': u'StaticVocabularyConstraint_eid',
   248               'value': u"u'?1', u'11'"}),
   249               'value': u"u'?1', u'11'"}),
   249 
   250 
   250             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   251             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   251              'X description %(description)s,X fulltextindexed %(fulltextindexed)s,'
   252              'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
   252              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   253              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   253              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE '
   254              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE '
   254              'WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   255              'WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   255              {'se': None,
   256              {'se': None,
   256               'rt': None,
   257               'rt': None,
   259               'internationalizable': True,
   260               'internationalizable': True,
   260               'fulltextindexed': False,
   261               'fulltextindexed': False,
   261               'ordernum': 5,
   262               'ordernum': 5,
   262               'defaultval': None,
   263               'defaultval': None,
   263               'indexed': False,
   264               'indexed': False,
       
   265               'formula': None,
   264               'cardinality': u'?1'}),
   266               'cardinality': u'?1'}),
   265             ('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 '
   266              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   268              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   267              {'x': None,
   269              {'x': None,
   268               'ct': u'SizeConstraint_eid',
   270               'ct': u'SizeConstraint_eid',
   271              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   273              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   272              {'x': None,
   274              {'x': None,
   273               'ct': u'StaticVocabularyConstraint_eid',
   275               'ct': u'StaticVocabularyConstraint_eid',
   274               'value': (u"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', "
   276               'value': (u"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', "
   275                         "u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'")})],
   277                         "u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'")})],
   276                              list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
   278               list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
   277 
   279 
   278     def test_rschema2rql_custom_type(self):
   280     def test_rschema2rql_custom_type(self):
   279         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
   281         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
   280                      'X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,'
   282                      'X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,'
   281                      'X name %(name)s,X symmetric %(symmetric)s',
   283                      'X name %(name)s,X symmetric %(symmetric)s',
   285                       'inlined': False,
   287                       'inlined': False,
   286                       'name': u'custom_field_of_jungle',
   288                       'name': u'custom_field_of_jungle',
   287                       'symmetric': False}),
   289                       'symmetric': False}),
   288                      ('INSERT CWAttribute X: X cardinality %(cardinality)s,'
   290                      ('INSERT CWAttribute X: X cardinality %(cardinality)s,'
   289                       'X defaultval %(defaultval)s,X description %(description)s,'
   291                       'X defaultval %(defaultval)s,X description %(description)s,'
   290                       'X extra_props %(extra_props)s,X indexed %(indexed)s,'
   292                       'X extra_props %(extra_props)s,X formula %(formula)s,X indexed %(indexed)s,'
   291                       'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
   293                       'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
   292                       'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   294                       'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   293                       {'cardinality': u'?1',
   295                       {'cardinality': u'?1',
   294                        'defaultval': None,
   296                        'defaultval': None,
   295                        'description': u'',
   297                        'description': u'',
   296                        'extra_props': '{"jungle_speed": 42}',
   298                        'extra_props': '{"jungle_speed": 42}',
       
   299                        'formula': None,
   297                        'indexed': False,
   300                        'indexed': False,
   298                        'oe': None,
   301                        'oe': None,
   299                        'ordernum': 4,
   302                        'ordernum': 4,
   300                        'rt': None,
   303                        'rt': None,
   301                        'se': None})]
   304                        'se': None})]
   311         self.assertListEqual(expected, got)
   314         self.assertListEqual(expected, got)
   312 
   315 
   313     def test_rdef2rql(self):
   316     def test_rdef2rql(self):
   314         self.assertListEqual([
   317         self.assertListEqual([
   315             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   318             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,'
   316              'X description %(description)s,X fulltextindexed %(fulltextindexed)s,'
   319              'X description %(description)s,X formula %(formula)s,X fulltextindexed %(fulltextindexed)s,'
   317              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   320              'X indexed %(indexed)s,X internationalizable %(internationalizable)s,'
   318              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
   321              'X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,'
   319              'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   322              'X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   320              {'se': None,
   323              {'se': None,
   321               'rt': None,
   324               'rt': None,
   324               'internationalizable': True,
   327               'internationalizable': True,
   325               'fulltextindexed': False,
   328               'fulltextindexed': False,
   326               'ordernum': 3,
   329               'ordernum': 3,
   327               'defaultval': Binary('text/plain'),
   330               'defaultval': Binary('text/plain'),
   328               'indexed': False,
   331               'indexed': False,
       
   332               'formula': None,
   329               'cardinality': u'?1'}),
   333               'cardinality': u'?1'}),
   330             ('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 '
   331              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   335              'WHERE CT eid %(ct)s, EDEF eid %(x)s',
   332              {'x': None,
   336              {'x': None,
   333               'value': u'None',
   337               'value': u'None',