--- a/server/test/unittest_schemaserial.py Fri Jun 14 16:26:25 2013 +0200
+++ b/server/test/unittest_schemaserial.py Wed Jun 26 14:22:22 2013 +0200
@@ -63,29 +63,29 @@
class Schema2RQLTC(TestCase):
def test_eschema2rql1(self):
- self.assertListEqual(list(eschema2rql(schema.eschema('CWAttribute'))),
- [
+ self.assertListEqual([
('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
{'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',
- 'name': u'CWAttribute', 'final': False})
- ])
+ 'name': u'CWAttribute', 'final': False})],
+ list(eschema2rql(schema.eschema('CWAttribute'))))
def test_eschema2rql2(self):
- self.assertListEqual(list(eschema2rql(schema.eschema('String'))), [
+ self.assertListEqual([
('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
- {'description': u'', 'final': True, 'name': u'String'})])
+ {'description': u'', 'final': True, 'name': u'String'})],
+ list(eschema2rql(schema.eschema('String'))))
def test_eschema2rql_specialization(self):
# x: None since eschema.eid are None
- self.assertListEqual(sorted(specialize2rql(schema)),
- [('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
- {'et': None, 'x': None}),
- ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
- {'et': None, 'x': None}),
- ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
- {'et': None, 'x': None}),
- ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
- {'et': None, 'x': None})])
+ self.assertListEqual([('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
+ {'et': None, 'x': None}),
+ ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
+ {'et': None, 'x': None}),
+ ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
+ {'et': None, 'x': None}),
+ ('SET X specializes ET WHERE X eid %(x)s, ET eid %(et)s',
+ {'et': None, 'x': None})],
+ sorted(specialize2rql(schema)))
def test_esche2rql_custom_type(self):
expected = [('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
@@ -95,8 +95,7 @@
self.assertListEqual(expected, got)
def test_rschema2rql1(self):
- self.assertListEqual(list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)),
- [
+ self.assertListEqual([
('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'link a relation definition to its relation type', 'symmetric': False, 'name': u'relation_type', 'final' : False, 'fulltext_container': None, 'inlined': True}),
@@ -113,11 +112,11 @@
'ordernum': 1, 'cardinality': u'1*'}),
('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'RQLConstraint_eid', 'value': u';O;O final FALSE\n'}),
- ])
+ ],
+ list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)))
def test_rschema2rql2(self):
- self.assertListEqual(list(rschema2rql(schema.rschema('add_permission'), cstrtypemap)),
- [
+ self.assertListEqual([
('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}),
('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,12 +131,11 @@
'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'ordernum': 9999, 'cardinality': u'**'}),
('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',
{'se': None, 'rt': None, 'oe': None,
- 'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'ordernum': 9999, 'cardinality': u'*?'}),
- ])
+ 'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'ordernum': 9999, 'cardinality': u'*?'})],
+ list(rschema2rql(schema.rschema('add_permission'), cstrtypemap)))
def test_rschema2rql3(self):
- self.assertListEqual(list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)),
- [
+ self.assertListEqual([
('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'cardinality', 'final': True, 'fulltext_container': None, 'inlined': False}),
@@ -155,8 +153,8 @@
('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'SizeConstraint_eid', 'value': u'max=2'}),
('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"u'?*', u'1*', u'+*', u'**', u'?+', u'1+', u'++', u'*+', u'?1', u'11', u'+1', u'*1', u'??', u'1?', u'+?', u'*?'"}),
- ])
+ {'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'*?'"})],
+ list(rschema2rql(schema.rschema('cardinality'), cstrtypemap)))
def test_rschema2rql_custom_type(self):
expected = [('INSERT CWRType X: X description %(description)s,X final %(final)s,'
@@ -195,37 +193,34 @@
self.assertListEqual(expected, got)
def test_rdef2rql(self):
- self.assertListEqual(list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')], cstrtypemap)),
- [
+ self.assertListEqual([
('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',
{'se': None, 'rt': None, 'oe': None,
'description': u'', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 3, 'defaultval': u'text/plain', 'indexed': False, 'cardinality': u'?1'}),
('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', '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', 'ct': 'SizeConstraint_eid'})])
+ {'x': None, 'value': u'max=50', 'ct': 'SizeConstraint_eid'})],
+ list(rdef2rql(schema['description_format'].rdefs[('CWRType', 'String')], cstrtypemap)))
def test_updateeschema2rql1(self):
- self.assertListEqual(list(updateeschema2rql(schema.eschema('CWAttribute'), 1)),
- [('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
- {'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'}),
- ])
+ self.assertListEqual([('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
+ {'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'})],
+ list(updateeschema2rql(schema.eschema('CWAttribute'), 1)))
def test_updateeschema2rql2(self):
- self.assertListEqual(list(updateeschema2rql(schema.eschema('String'), 1)),
- [('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
- {'description': u'', 'x': 1, 'final': True, 'name': u'String'})
- ])
+ self.assertListEqual([('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X eid %(x)s',
+ {'description': u'', 'x': 1, 'final': True, 'name': u'String'})],
+ list(updateeschema2rql(schema.eschema('String'), 1)))
def test_updaterschema2rql1(self):
- self.assertListEqual(list(updaterschema2rql(schema.rschema('relation_type'), 1)),
- [
+ self.assertListEqual([
('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',
{'x': 1, 'symmetric': False,
'description': u'link a relation definition to its relation type',
- 'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'})
- ])
+ 'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'})],
+ list(updaterschema2rql(schema.rschema('relation_type'), 1)))
def test_updaterschema2rql2(self):
expected = [
@@ -235,7 +230,7 @@
'inlined': False, 'name': u'add_permission'})
]
for i, (rql, args) in enumerate(updaterschema2rql(schema.rschema('add_permission'), 1)):
- yield self.assertEqual, (rql, args), expected[i]
+ yield self.assertEqual, expected[i], (rql, args)
class Perms2RQLTC(TestCase):
GROUP_MAPPING = {
@@ -246,31 +241,34 @@
}
def test_eperms2rql1(self):
- self.assertListEqual([(rql, kwargs) for rql, kwargs in erperms2rql(schema.eschema('CWEType'), self.GROUP_MAPPING)],
- [('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
- ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
- ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ])
+ self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
+ ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
+ ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0})],
+ [(rql, kwargs)
+ for rql, kwargs in erperms2rql(schema.eschema('CWEType'), self.GROUP_MAPPING)])
def test_rperms2rql2(self):
- self.assertListEqual([(rql, kwargs) for rql, kwargs in erperms2rql(schema.rschema('read_permission').rdef('CWEType', 'CWGroup'), self.GROUP_MAPPING)],
- [('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
- ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
- ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ])
+ self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
+ ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
+ ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X delete_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0})],
+ [(rql, kwargs)
+ for rql, kwargs in erperms2rql(schema.rschema('read_permission').rdef('CWEType', 'CWGroup'),
+ self.GROUP_MAPPING)])
def test_rperms2rql3(self):
- self.assertListEqual([(rql, kwargs) for rql, kwargs in erperms2rql(schema.rschema('name').rdef('CWEType', 'String'), self.GROUP_MAPPING)],
- [('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
- ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
- ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
- ])
+ self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 1}),
+ ('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 2}),
+ ('SET X add_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
+ ('SET X update_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0})],
+ [(rql, kwargs)
+ for rql, kwargs in erperms2rql(schema.rschema('name').rdef('CWEType', 'String'),
+ self.GROUP_MAPPING)])
#def test_perms2rql(self):
# self.assertListEqual(perms2rql(schema, self.GROUP_MAPPING),