author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 05 Feb 2010 11:56:57 +0100 | |
changeset 4467 | 0e73d299730a |
parent 4191 | 01638461d4b0 |
child 4680 | 8a6bee838464 |
permissions | -rw-r--r-- |
0 | 1 |
"""unit tests for schema rql (de)serialization |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
2 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 3 |
""" |
4 |
||
5 |
import sys |
|
6 |
from cStringIO import StringIO |
|
7 |
||
8 |
from logilab.common.testlib import TestCase, unittest_main |
|
9 |
||
10 |
from cubicweb.schema import CubicWebSchemaLoader |
|
11 |
from cubicweb.devtools import TestServerConfiguration |
|
12 |
||
13 |
loader = CubicWebSchemaLoader() |
|
14 |
config = TestServerConfiguration('data') |
|
15 |
config.bootstrap_cubes() |
|
16 |
schema = loader.load(config) |
|
17 |
||
18 |
from cubicweb.server.schemaserial import * |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
19 |
from cubicweb.server.schemaserial import _erperms2rql as erperms2rql |
1787 | 20 |
|
0 | 21 |
class Schema2RQLTC(TestCase): |
1787 | 22 |
|
0 | 23 |
def test_eschema2rql1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
24 |
self.assertListEquals(list(eschema2rql(schema.eschema('CWAttribute'))), |
0 | 25 |
[ |
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
26 |
('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s', |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2447
diff
changeset
|
27 |
{'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', |
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
28 |
'name': u'CWAttribute', 'final': False}) |
0 | 29 |
]) |
1787 | 30 |
|
0 | 31 |
def test_eschema2rql2(self): |
32 |
self.assertListEquals(list(eschema2rql(schema.eschema('String'))), [ |
|
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
33 |
('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s', |
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
34 |
{'description': u'', 'final': True, 'name': u'String'})]) |
1787 | 35 |
|
0 | 36 |
def test_eschema2rql_specialization(self): |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
37 |
self.assertListEquals(sorted(specialize2rql(schema)), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
38 |
[('SET X specializes ET WHERE X name %(x)s, ET name %(et)s', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
39 |
{'et': 'BaseTransition', 'x': 'Transition'}), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
40 |
('SET X specializes ET WHERE X name %(x)s, ET name %(et)s', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
41 |
{'et': 'BaseTransition', 'x': 'WorkflowTransition'}), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
42 |
('SET X specializes ET WHERE X name %(x)s, ET name %(et)s', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
43 |
{'et': 'Division', 'x': 'SubDivision'}), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
44 |
# ('SET X specializes ET WHERE X name %(x)s, ET name %(et)s', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
45 |
# {'et': 'File', 'x': 'Image'}), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
46 |
('SET X specializes ET WHERE X name %(x)s, ET name %(et)s', |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
47 |
{'et': 'Societe', 'x': 'Division'})]) |
1787 | 48 |
|
0 | 49 |
def test_rschema2rql1(self): |
50 |
self.assertListEquals(list(rschema2rql(schema.rschema('relation_type'))), |
|
51 |
[ |
|
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
52 |
('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', |
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
53 |
{'description': u'link a relation definition to its relation type', 'symmetric': False, 'name': u'relation_type', 'final' : False, 'fulltext_container': None, 'inlined': True}), |
1787 | 54 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
55 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
56 |
{'rt': 'relation_type', 'description': u'', 'composite': u'object', 'oe': 'CWRType', |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
57 |
'ordernum': 1, 'cardinality': u'1*', 'se': 'CWAttribute'}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
58 |
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT name %(ctname)s, EDEF relation_type ER, EDEF from_entity SE, EDEF to_entity OE, ER name %(rt)s, SE name %(se)s, OE name %(oe)s, EDEF is CWRelation', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
59 |
{'rt': 'relation_type', 'oe': 'CWRType', 'ctname': u'RQLConstraint', 'se': 'CWAttribute', 'value': u';O;O final TRUE\n'}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
60 |
|
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
61 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
62 |
{'rt': 'relation_type', 'description': u'', 'composite': u'object', 'oe': 'CWRType', |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
63 |
'ordernum': 1, 'cardinality': u'1*', 'se': 'CWRelation'}), |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
64 |
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT name %(ctname)s, EDEF relation_type ER, EDEF from_entity SE, EDEF to_entity OE, ER name %(rt)s, SE name %(se)s, OE name %(oe)s, EDEF is CWRelation', |
3978
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3897
diff
changeset
|
65 |
{'rt': 'relation_type', 'oe': 'CWRType', 'ctname': u'RQLConstraint', 'se': 'CWRelation', 'value': u';O;O final FALSE\n'}), |
0 | 66 |
]) |
1787 | 67 |
|
0 | 68 |
def test_rschema2rql2(self): |
1787 | 69 |
self.assertListEquals(list(rschema2rql(schema.rschema('add_permission'))), |
70 |
[ |
|
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
71 |
('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'core relation giving to a group the permission to add an entity or relation type', 'symmetric': False, 'name': u'add_permission', 'final': False, 'fulltext_container': None, 'inlined': False}), |
1787 | 72 |
|
73 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
74 |
{'rt': 'add_permission', 'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'oe': 'CWGroup', 'ordernum': 3, 'cardinality': u'**', 'se': 'CWAttribute'}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
75 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
76 |
{'rt': 'add_permission', 'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'oe': 'RQLExpression', 'ordernum': 5, 'cardinality': u'*?', 'se': 'CWAttribute'}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
77 |
|
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
78 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
1787 | 79 |
{'rt': 'add_permission', 'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'oe': 'CWGroup', 'ordernum': 3, 'cardinality': u'**', 'se': 'CWEType'}), |
80 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
81 |
{'rt': 'add_permission', 'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'oe': 'RQLExpression', 'ordernum': 5, 'cardinality': u'*?', 'se': 'CWEType'}), |
1787 | 82 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
83 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
84 |
{'rt': 'add_permission', 'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'oe': 'CWGroup', 'ordernum': 3, 'cardinality': u'**', 'se': 'CWRelation'}), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
85 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
86 |
{'rt': 'add_permission', 'description': u'rql expression allowing to add entities/relations of this type', 'composite': 'subject', 'oe': 'RQLExpression', 'ordernum': 5, 'cardinality': u'*?', 'se': 'CWRelation'}), |
1787 | 87 |
]) |
88 |
||
0 | 89 |
def test_rschema2rql3(self): |
1787 | 90 |
self.assertListEquals(list(rschema2rql(schema.rschema('cardinality'))), |
0 | 91 |
[ |
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
92 |
('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', |
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
93 |
{'description': u'', 'symmetric': False, 'name': u'cardinality', 'final': True, 'fulltext_container': None, 'inlined': False}), |
0 | 94 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
95 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
96 |
{'rt': 'cardinality', 'description': u'subject/object cardinality', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 5, 'defaultval': None, 'indexed': False, 'cardinality': u'?1', 'oe': 'String', 'se': 'CWAttribute'}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
97 |
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT name %(ctname)s, EDEF relation_type ER, EDEF from_entity SE, EDEF to_entity OE, ER name %(rt)s, SE name %(se)s, OE name %(oe)s, EDEF is CWAttribute', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
98 |
{'rt': 'cardinality', 'oe': 'String', 'ctname': u'SizeConstraint', 'se': 'CWAttribute', 'value': u'max=2'}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
99 |
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT name %(ctname)s, EDEF relation_type ER, EDEF from_entity SE, EDEF to_entity OE, ER name %(rt)s, SE name %(se)s, OE name %(oe)s, EDEF is CWAttribute', |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
100 |
{'rt': 'cardinality', 'oe': 'String', 'ctname': u'StaticVocabularyConstraint', 'se': 'CWAttribute', 'value': u"u'?1', u'11'"}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
101 |
|
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
102 |
('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 name %(se)s,ER name %(rt)s,OE name %(oe)s', |
1787 | 103 |
{'rt': 'cardinality', 'description': u'subject/object cardinality', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 5, 'defaultval': None, 'indexed': False, 'cardinality': u'?1', 'oe': 'String', 'se': 'CWRelation'}), |
104 |
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT name %(ctname)s, EDEF relation_type ER, EDEF from_entity SE, EDEF to_entity OE, ER name %(rt)s, SE name %(se)s, OE name %(oe)s, EDEF is CWAttribute', |
|
105 |
{'rt': 'cardinality', 'oe': 'String', 'ctname': u'SizeConstraint', 'se': 'CWRelation', 'value': u'max=2'}), |
|
106 |
('INSERT CWConstraint X: X value %(value)s, X cstrtype CT, EDEF constrained_by X WHERE CT name %(ctname)s, EDEF relation_type ER, EDEF from_entity SE, EDEF to_entity OE, ER name %(rt)s, SE name %(se)s, OE name %(oe)s, EDEF is CWAttribute', |
|
107 |
{'rt': 'cardinality', 'oe': 'String', 'ctname': u'StaticVocabularyConstraint', 'se': 'CWRelation', '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'*?'"}), |
|
108 |
]) |
|
0 | 109 |
|
110 |
||
111 |
def test_updateeschema2rql1(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
112 |
self.assertListEquals(list(updateeschema2rql(schema.eschema('CWAttribute'))), |
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
113 |
[('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X is CWEType, X name %(et)s', |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2447
diff
changeset
|
114 |
{'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', 'et': 'CWAttribute', 'final': False, 'name': u'CWAttribute'}), |
0 | 115 |
]) |
1787 | 116 |
|
0 | 117 |
def test_updateeschema2rql2(self): |
118 |
self.assertListEquals(list(updateeschema2rql(schema.eschema('String'))), |
|
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
119 |
[('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X is CWEType, X name %(et)s', |
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
120 |
{'description': u'', 'et': 'String', 'final': True, 'name': u'String'}) |
0 | 121 |
]) |
1787 | 122 |
|
0 | 123 |
def test_updaterschema2rql1(self): |
124 |
self.assertListEquals(list(updaterschema2rql(schema.rschema('relation_type'))), |
|
125 |
[ |
|
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
126 |
('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 is CWRType, X name %(rt)s', |
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
127 |
{'rt': 'relation_type', 'symmetric': False, |
0 | 128 |
'description': u'link a relation definition to its relation type', |
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
129 |
'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'}) |
0 | 130 |
]) |
1787 | 131 |
|
0 | 132 |
def test_updaterschema2rql2(self): |
133 |
expected = [ |
|
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
134 |
('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 is CWRType, X name %(rt)s', |
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
135 |
{'rt': 'add_permission', 'symmetric': False, |
0 | 136 |
'description': u'core relation giving to a group the permission to add an entity or relation type', |
2447
b83fcc2311af
fix schemaserial tests: meta doesn't exist anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2200
diff
changeset
|
137 |
'final': False, 'fulltext_container': None, 'inlined': False, 'name': u'add_permission'}) |
0 | 138 |
] |
139 |
for i, (rql, args) in enumerate(updaterschema2rql(schema.rschema('add_permission'))): |
|
140 |
yield self.assertEquals, (rql, args), expected[i] |
|
141 |
||
142 |
class Perms2RQLTC(TestCase): |
|
143 |
GROUP_MAPPING = { |
|
144 |
'managers': 0, |
|
145 |
'users': 1, |
|
146 |
'guests': 2, |
|
147 |
'owners': 3, |
|
148 |
} |
|
1787 | 149 |
|
0 | 150 |
def test_eperms2rql1(self): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
151 |
self.assertListEquals([(rql, kwargs) for rql, kwargs in erperms2rql(schema.eschema('CWEType'), self.GROUP_MAPPING)], |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
152 |
[('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
153 |
('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 1}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
154 |
('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 2}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
155 |
('SET X add_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
156 |
('SET X update_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
157 |
('SET X update_permission Y WHERE Y eid %(g)s, ', {'g': 3}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
158 |
('SET X delete_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
0 | 159 |
]) |
1787 | 160 |
|
0 | 161 |
def test_rperms2rql2(self): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
162 |
self.assertListEquals([(rql, kwargs) for rql, kwargs in erperms2rql(schema.rschema('read_permission').rdef('CWEType', 'CWGroup'), self.GROUP_MAPPING)], |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
163 |
[('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
164 |
('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 1}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
165 |
('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 2}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
166 |
('SET X add_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
167 |
('SET X delete_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
0 | 168 |
]) |
1787 | 169 |
|
0 | 170 |
def test_rperms2rql3(self): |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
171 |
self.assertListEquals([(rql, kwargs) for rql, kwargs in erperms2rql(schema.rschema('name').rdef('CWEType', 'String'), self.GROUP_MAPPING)], |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
172 |
[('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
173 |
('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 1}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
174 |
('SET X read_permission Y WHERE Y eid %(g)s, ', {'g': 2}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
175 |
('SET X add_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
176 |
('SET X add_permission Y WHERE Y eid %(g)s, ', {'g': 1}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
177 |
('SET X delete_permission Y WHERE Y eid %(g)s, ', {'g': 0}), |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
178 |
('SET X delete_permission Y WHERE Y eid %(g)s, ', {'g': 1}), |
0 | 179 |
]) |
1787 | 180 |
|
0 | 181 |
#def test_perms2rql(self): |
182 |
# self.assertListEquals(perms2rql(schema, self.GROUP_MAPPING), |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
183 |
# ['INSERT CWEType X: X name 'Societe', X final FALSE']) |
1787 | 184 |
|
0 | 185 |
|
186 |
||
187 |
if __name__ == '__main__': |
|
188 |
unittest_main() |