--- a/cubicweb/server/test/unittest_schemaserial.py Fri Jul 08 10:17:42 2016 +0200
+++ b/cubicweb/server/test/unittest_schemaserial.py Fri Jul 08 09:59:18 2016 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of CubicWeb.
@@ -58,6 +58,7 @@
'FormatConstraint': 'FormatConstraint_eid',
}
+
class Schema2RQLTC(TestCase):
def test_eschema2rql1(self):
@@ -71,8 +72,8 @@
def test_eschema2rql2(self):
self.assertListEqual([
- ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
- {'description': u'', 'final': True, 'name': u'String'})],
+ ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
+ {'description': u'', 'final': True, 'name': u'String'})],
list(eschema2rql(schema.eschema('String'))))
def test_eschema2rql_specialization(self):
@@ -87,7 +88,7 @@
expected = [('INSERT CWEType X: X description %(description)s,X final %(final)s,'
'X name %(name)s',
{'description': u'',
- 'name': u'BabarTestType', 'final': True},)]
+ 'name': u'BabarTestType', 'final': True},)]
got = list(eschema2rql(schema.eschema('BabarTestType')))
self.assertListEqual(expected, got)
@@ -99,7 +100,7 @@
{'description': u'link a relation definition to its relation type',
'symmetric': False,
'name': u'relation_type',
- 'final' : False,
+ 'final': False,
'fulltext_container': None,
'inlined': True}),
@@ -124,7 +125,8 @@
'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'{"expression": "O final FALSE", "mainvars": ["O"], "msg": null}'}),
+ {'x': None, 'ct': u'RQLConstraint_eid',
+ 'value': u'{"expression": "O final FALSE", "mainvars": ["O"], "msg": null}'}),
],
list(rschema2rql(schema.rschema('relation_type'), cstrtypemap)))
@@ -184,13 +186,13 @@
('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',
- {'cardinality': u'**',
- 'composite': None,
- 'description': u'groups allowed to add entities/relations of this type',
- 'oe': None,
- 'ordernum': 9999,
- 'rt': None,
- 'se': None}),
+ {'cardinality': u'**',
+ 'composite': None,
+ 'description': u'groups allowed to add entities/relations of this type',
+ 'oe': None,
+ 'ordernum': 9999,
+ 'rt': None,
+ 'se': None}),
('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',
@@ -387,10 +389,10 @@
class Perms2RQLTC(TestCase):
GROUP_MAPPING = {
'managers': 0,
- 'users': 1,
+ 'users': 1,
'guests': 2,
'owners': 3,
- }
+ }
def test_eperms2rql1(self):
self.assertListEqual([('SET X read_permission Y WHERE Y eid %(g)s, X eid %(x)s', {'g': 0}),
@@ -422,9 +424,6 @@
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),
- # ['INSERT CWEType X: X name 'Societe', X final FALSE'])
class ComputedAttributeAndRelationTC(CubicWebTC):
appid = 'data-cwep002'
@@ -442,6 +441,7 @@
self.assertEqual('Any SUM(SA) GROUPBY X WHERE P works_for X, P salary SA',
schema['total_salary'].rdefs['Company', 'Int'].formula)
+
if __name__ == '__main__':
from unittest import main
main()