server/test/unittest_schemaserial.py
branchstable
changeset 9128 d988eec2d5d3
parent 8945 ba9e3fbfa5a5
child 9140 e7ffe39d4b1a
equal deleted inserted replaced
9013:b4bcabf55e77 9128:d988eec2d5d3
    61                }
    61                }
    62 
    62 
    63 class Schema2RQLTC(TestCase):
    63 class Schema2RQLTC(TestCase):
    64 
    64 
    65     def test_eschema2rql1(self):
    65     def test_eschema2rql1(self):
    66         self.assertListEqual(list(eschema2rql(schema.eschema('CWAttribute'))),
    66         self.assertListEqual([
    67                               [
       
    68             ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
    67             ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
    69              {'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the instance schema',
    68              {'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the instance schema',
    70               'name': u'CWAttribute', 'final': False})
    69               'name': u'CWAttribute', 'final': False})],
    71             ])
    70                              list(eschema2rql(schema.eschema('CWAttribute'))))
    72 
    71 
    73     def test_eschema2rql2(self):
    72     def test_eschema2rql2(self):
    74         self.assertListEqual(list(eschema2rql(schema.eschema('String'))), [
    73         self.assertListEqual([
    75                 ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
    74                 ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
    76                  {'description': u'', 'final': True, 'name': u'String'})])
    75                  {'description': u'', 'final': True, 'name': u'String'})],
       
    76                              list(eschema2rql(schema.eschema('String'))))
    77 
    77 
    78     def test_eschema2rql_specialization(self):
    78     def test_eschema2rql_specialization(self):
    79         # x: None since eschema.eid are None
    79         # x: None since eschema.eid are None
    80         self.assertListEqual(sorted(specialize2rql(schema)),
    80         self.assertListEqual([('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    81                               [('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    81                                {'et': None, 'x': None}),
    82                                 {'et': None, 'x': None}),
    82                               ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    83                                ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    83                                {'et': None, 'x': None}),
    84                                 {'et': None, 'x': None}),
    84                               ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    85                                ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    85                                {'et': None, 'x': None}),
    86                                 {'et': None, 'x': None}),
    86                               ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    87                                ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
    87                                {'et': None, 'x': None})],
    88                                 {'et': None, 'x': None})])
    88                              sorted(specialize2rql(schema)))
    89 
    89 
    90     def test_esche2rql_custom_type(self):
    90     def test_esche2rql_custom_type(self):
    91         expected = [('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
    91         expected = [('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
    92                      {'description': u'',
    92                      {'description': u'',
    93                      'name': u'BabarTestType', 'final': True},)]
    93                      'name': u'BabarTestType', 'final': True},)]
    94         got = list(eschema2rql(schema.eschema('BabarTestType')))
    94         got = list(eschema2rql(schema.eschema('BabarTestType')))
    95         self.assertListEqual(expected, got)
    95         self.assertListEqual(expected, got)
    96 
    96 
    97     def test_rschema2rql1(self):
    97     def test_rschema2rql1(self):
    98         self.assertListEqual(list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)),
    98         self.assertListEqual([
    99                              [
       
   100             ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s',
    99             ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s',
   101              {'description': u'link a relation definition to its relation type', 'symmetric': False, 'name': u'relation_type', 'final' : False, 'fulltext_container': None, 'inlined': True}),
   100              {'description': u'link a relation definition to its relation type', 'symmetric': False, 'name': u'relation_type', 'final' : False, 'fulltext_container': None, 'inlined': True}),
   102 
   101 
   103             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   102             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   104              {'se': None, 'rt': None, 'oe': None,
   103              {'se': None, 'rt': None, 'oe': None,
   111              {'se': None, 'rt': None, 'oe': None,
   110              {'se': None, 'rt': None, 'oe': None,
   112               'description': u'', 'composite': u'object', 
   111               'description': u'', 'composite': u'object', 
   113               'ordernum': 1, 'cardinality': u'1*'}),
   112               'ordernum': 1, 'cardinality': u'1*'}),
   114             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   113             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   115              {'x': None, 'ct': u'RQLConstraint_eid', 'value': u';O;O final FALSE\n'}),
   114              {'x': None, 'ct': u'RQLConstraint_eid', 'value': u';O;O final FALSE\n'}),
   116             ])
   115         ],
       
   116                              list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)))
   117 
   117 
   118     def test_rschema2rql2(self):
   118     def test_rschema2rql2(self):
   119         self.assertListEqual(list(rschema2rql(schema.rschema('add_permission'), cstrtypemap)),
   119         self.assertListEqual([
   120                               [
       
   121             ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s', {'description': u'', 'symmetric': False, 'name': u'add_permission', 'final': False, 'fulltext_container': None, 'inlined': False}),
   120             ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s', {'description': u'', 'symmetric': False, 'name': u'add_permission', 'final': False, 'fulltext_container': None, 'inlined': False}),
   122 
   121 
   123             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   122             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   124              {'se': None, 'rt': None, 'oe': None,
   123              {'se': None, 'rt': None, 'oe': None,
   125               'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'ordernum': 9999, 'cardinality': u'**'}),
   124               'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'ordernum': 9999, 'cardinality': u'**'}),
   130             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   129             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   131              {'se': None, 'rt': None, 'oe': None,
   130              {'se': None, 'rt': None, 'oe': None,
   132               'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'ordernum': 9999, 'cardinality': u'**'}),
   131               'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'ordernum': 9999, 'cardinality': u'**'}),
   133             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   132             ('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   134              {'se': None, 'rt': None, 'oe': None,
   133              {'se': None, 'rt': None, 'oe': None,
   135               'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'ordernum': 9999, 'cardinality': u'*?'}),
   134               'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'ordernum': 9999, 'cardinality': u'*?'})],
   136             ])
   135                              list(rschema2rql(schema.rschema('add_permission'), cstrtypemap)))
   137 
   136 
   138     def test_rschema2rql3(self):
   137     def test_rschema2rql3(self):
   139         self.assertListEqual(list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)),
   138         self.assertListEqual([
   140                              [
       
   141             ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s',
   139             ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s',
   142              {'description': u'', 'symmetric': False, 'name': u'cardinality', 'final': True, 'fulltext_container': None, 'inlined': False}),
   140              {'description': u'', 'symmetric': False, 'name': u'cardinality', 'final': True, 'fulltext_container': None, 'inlined': False}),
   143 
   141 
   144             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   142             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   145              {'se': None, 'rt': None, 'oe': None,
   143              {'se': None, 'rt': None, 'oe': None,
   153              {'se': None, 'rt': None, 'oe': None,
   151              {'se': None, 'rt': None, 'oe': None,
   154               'description': u'subject/object cardinality', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 5, 'defaultval': None, 'indexed': False, 'cardinality': u'?1'}),
   152               'description': u'subject/object cardinality', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 5, 'defaultval': None, 'indexed': False, 'cardinality': u'?1'}),
   155             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   153             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   156              {'x': None, 'ct': u'SizeConstraint_eid', 'value': u'max=2'}),
   154              {'x': None, 'ct': u'SizeConstraint_eid', 'value': u'max=2'}),
   157             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   155             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   158              {'x': None, 'ct': u'StaticVocabularyConstraint_eid', 'value': u"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'"}),
   156              {'x': None, 'ct': u'StaticVocabularyConstraint_eid', 'value': u"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'"})],
   159             ])
   157                              list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
   160 
   158 
   161     def test_rschema2rql_custom_type(self):
   159     def test_rschema2rql_custom_type(self):
   162         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
   160         expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
   163                      'X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,'
   161                      'X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,'
   164                      'X name %(name)s,X symmetric %(symmetric)s',
   162                      'X name %(name)s,X symmetric %(symmetric)s',
   193         self.assertIsInstance(extra_props, Binary)
   191         self.assertIsInstance(extra_props, Binary)
   194         got[1][1]['extra_props'] = got[1][1]['extra_props'].getvalue()
   192         got[1][1]['extra_props'] = got[1][1]['extra_props'].getvalue()
   195         self.assertListEqual(expected, got)
   193         self.assertListEqual(expected, got)
   196 
   194 
   197     def test_rdef2rql(self):
   195     def test_rdef2rql(self):
   198         self.assertListEqual(list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')], cstrtypemap)),
   196         self.assertListEqual([
   199                               [
       
   200             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   197             ('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE eid %(se)s,ER eid %(rt)s,OE eid %(oe)s',
   201              {'se': None, 'rt': None, 'oe': None,
   198              {'se': None, 'rt': None, 'oe': None,
   202               'description': u'', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 3, 'defaultval': u'text/plain', 'indexed': False, 'cardinality': u'?1'}),
   199               'description': u'', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 3, 'defaultval': u'text/plain', 'indexed': False, 'cardinality': u'?1'}),
   203             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   200             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   204              {'x': None, 'value': u'None', 'ct': 'FormatConstraint_eid'}),
   201              {'x': None, 'value': u'None', 'ct': 'FormatConstraint_eid'}),
   205             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   202             ('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT eid %(ct)s, EDEF eid %(x)s',
   206              {'x': None, 'value': u'max=50', 'ct': 'SizeConstraint_eid'})])
   203              {'x': None, 'value': u'max=50', 'ct': 'SizeConstraint_eid'})],
       
   204                              list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')], cstrtypemap)))
   207 
   205 
   208 
   206 
   209     def test_updateeschema2rql1(self):
   207     def test_updateeschema2rql1(self):
   210         self.assertListEqual(list(updateeschema2rql(schema.eschema('CWAttribute'), 1)),
   208         self.assertListEqual([('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
   211                               [('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
   209                                {'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the instance schema', 'x': 1, 'final': False, 'name': u'CWAttribute'})],
   212                                 {'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the instance schema', 'x': 1, 'final': False, 'name': u'CWAttribute'}),
   210                              list(updateeschema2rql(schema.eschema('CWAttribute'), 1)))
   213                                ])
       
   214 
   211 
   215     def test_updateeschema2rql2(self):
   212     def test_updateeschema2rql2(self):
   216         self.assertListEqual(list(updateeschema2rql(schema.eschema('String'), 1)),
   213         self.assertListEqual([('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
   217                               [('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
   214                                {'description': u'', 'x': 1, 'final': True, 'name': u'String'})],
   218                                 {'description': u'', 'x': 1, 'final': True, 'name': u'String'})
   215                              list(updateeschema2rql(schema.eschema('String'), 1)))
   219                                ])
       
   220 
   216 
   221     def test_updaterschema2rql1(self):
   217     def test_updaterschema2rql1(self):
   222         self.assertListEqual(list(updaterschema2rql(schema.rschema('relation_type'), 1)),
   218         self.assertListEqual([
   223                              [
       
   224             ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s WHERE X eid %(x)s',
   219             ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s WHERE X eid %(x)s',
   225              {'x': 1, 'symmetric': False,
   220              {'x': 1, 'symmetric': False,
   226               'description': u'link a relation definition to its relation type',
   221               'description': u'link a relation definition to its relation type',
   227               'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'})
   222               'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'})],
   228             ])
   223                              list(updaterschema2rql(schema.rschema('relation_type'), 1)))
   229 
   224 
   230     def test_updaterschema2rql2(self):
   225     def test_updaterschema2rql2(self):
   231         expected = [
   226         expected = [
   232             ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s WHERE X eid %(x)s',
   227             ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symmetric %(symmetric)s WHERE X eid %(x)s',
   233              {'x': 1, 'symmetric': False,
   228              {'x': 1, 'symmetric': False,
   234               'description': u'', 'final': False, 'fulltext_container': None,
   229               'description': u'', 'final': False, 'fulltext_container': None,
   235               'inlined': False, 'name': u'add_permission'})
   230               'inlined': False, 'name': u'add_permission'})
   236             ]
   231             ]
   237         for i, (rql, args) in enumerate(updaterschema2rql(schema.rschema('add_permission'), 1)):
   232         for i, (rql, args) in enumerate(updaterschema2rql(schema.rschema('add_permission'), 1)):
   238             yield self.assertEqual, (rql, args), expected[i]
   233             yield self.assertEqual, expected[i], (rql, args)
   239 
   234 
   240 class Perms2RQLTC(TestCase):
   235 class Perms2RQLTC(TestCase):
   241     GROUP_MAPPING = {
   236     GROUP_MAPPING = {
   242         'managers': 0,
   237         'managers': 0,
   243         'users':  1,
   238         'users':  1,
   244         'guests': 2,
   239         'guests': 2,
   245         'owners': 3,
   240         'owners': 3,
   246         }
   241         }
   247 
   242 
   248     def test_eperms2rql1(self):
   243     def test_eperms2rql1(self):
   249         self.assertListEqual([(rql, kwargs) for rql, kwargs in erperms2rql(schema.eschema('CWEType'), self.GROUP_MAPPING)],
   244         self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   250                               [('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   245                               ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
   251                                ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
   246                               ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
   252                                ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
   247                               ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   253                                ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   248                               ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   254                                ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   249                               ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0})],
   255                                ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   250                              [(rql, kwargs)
   256                                ])
   251                               for rql, kwargs in erperms2rql(schema.eschema('CWEType'), self.GROUP_MAPPING)])
   257 
   252 
   258     def test_rperms2rql2(self):
   253     def test_rperms2rql2(self):
   259         self.assertListEqual([(rql, kwargs) for rql, kwargs in erperms2rql(schema.rschema('read_permission').rdef('CWEType', 'CWGroup'), self.GROUP_MAPPING)],
   254         self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   260                               [('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   255                               ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
   261                                ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
   256                               ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
   262                                ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
   257                               ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   263                                ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   258                               ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0})],
   264                                ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   259                              [(rql, kwargs)
   265                                ])
   260                               for rql, kwargs in erperms2rql(schema.rschema('read_permission').rdef('CWEType', 'CWGroup'),
       
   261                                                              self.GROUP_MAPPING)])
   266 
   262 
   267     def test_rperms2rql3(self):
   263     def test_rperms2rql3(self):
   268         self.assertListEqual([(rql, kwargs) for rql, kwargs in erperms2rql(schema.rschema('name').rdef('CWEType', 'String'), self.GROUP_MAPPING)],
   264         self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   269                               [('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   265                               ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
   270                                ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
   266                               ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
   271                                ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
   267                               ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   272                                ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
   268                               ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0})],
   273                                ])
   269                              [(rql, kwargs)
       
   270                               for rql, kwargs in erperms2rql(schema.rschema('name').rdef('CWEType', 'String'),
       
   271                                                              self.GROUP_MAPPING)])
   274 
   272 
   275     #def test_perms2rql(self):
   273     #def test_perms2rql(self):
   276     #    self.assertListEqual(perms2rql(schema, self.GROUP_MAPPING),
   274     #    self.assertListEqual(perms2rql(schema, self.GROUP_MAPPING),
   277     #                         ['INSERT CWEType X: X name 'Societe', X final FALSE'])
   275     #                         ['INSERT CWEType X: X name 'Societe', X final FALSE'])
   278 
   276