author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 04 Nov 2014 14:10:02 +0100 | |
changeset 10024 | 2a08247b57fb |
parent 9990 | c84ad981fc4a |
child 10192 | 365e5a0287d6 |
permissions | -rw-r--r-- |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
1 |
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5179
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6117 | 18 |
"""unit tests for module cubicweb.schema""" |
0 | 19 |
|
20 |
import sys |
|
21 |
from os.path import join, isabs, basename, dirname |
|
22 |
||
23 |
from logilab.common.testlib import TestCase, unittest_main |
|
24 |
||
25 |
from rql import RQLSyntaxError |
|
26 |
||
7640
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
27 |
from yams import ValidationError, BadSchemaDefinition |
0 | 28 |
from yams.constraints import SizeConstraint, StaticVocabularyConstraint |
9952
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
29 |
from yams.buildobjs import (RelationDefinition, EntityType, RelationType, |
9966
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
30 |
Int, String, SubjectRelation, ComputedRelation) |
7469
f8c983afbf8e
[test] update cubicweb/test/unittest_schema.py (to follow yams#.....)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7460
diff
changeset
|
31 |
from yams.reader import fill_schema |
0 | 32 |
|
3978
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
33 |
from cubicweb.schema import ( |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
34 |
CubicWebSchema, CubicWebEntitySchema, CubicWebSchemaLoader, |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
35 |
RQLConstraint, RQLUniqueConstraint, RQLVocabularyConstraint, |
3998
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
36 |
RQLExpression, ERQLExpression, RRQLExpression, |
9952
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
37 |
normalize_expression, order_eschemas, guess_rrqlexpr_mainvars, |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
38 |
build_schema_from_namespace) |
0 | 39 |
from cubicweb.devtools import TestServerConfiguration as TestConfiguration |
7640
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
40 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 41 |
|
42 |
DATADIR = join(dirname(__file__), 'data') |
|
43 |
||
44 |
# build a dummy schema ######################################################## |
|
45 |
||
46 |
||
47 |
PERSONNE_PERMISSIONS = { |
|
48 |
'read': ('managers', 'users', 'guests'), |
|
49 |
'update': ('managers', 'owners'), |
|
50 |
'add': ('managers', ERQLExpression('X travaille S, S owned_by U')), |
|
51 |
'delete': ('managers', 'owners',), |
|
52 |
} |
|
53 |
||
54 |
CONCERNE_PERMISSIONS = { |
|
55 |
'read': ('managers', 'users', 'guests'), |
|
56 |
'add': ('managers', RRQLExpression('U has_update_permission S')), |
|
57 |
'delete': ('managers', RRQLExpression('O owned_by U')), |
|
58 |
} |
|
59 |
||
60 |
schema = CubicWebSchema('Test Schema') |
|
61 |
enote = schema.add_entity_type(EntityType('Note')) |
|
62 |
eaffaire = schema.add_entity_type(EntityType('Affaire')) |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
63 |
eperson = schema.add_entity_type(EntityType('Personne', __permissions__=PERSONNE_PERMISSIONS)) |
0 | 64 |
esociete = schema.add_entity_type(EntityType('Societe')) |
65 |
||
66 |
RELS = ( |
|
67 |
# attribute relations |
|
68 |
('Note date String'), |
|
69 |
('Note type String'), |
|
70 |
('Affaire sujet String'), |
|
71 |
('Affaire ref String'), |
|
72 |
('Personne nom String'), |
|
73 |
('Personne prenom String'), |
|
74 |
('Personne sexe String'), |
|
75 |
('Personne tel Int'), |
|
76 |
('Personne fax Int'), |
|
77 |
('Personne datenaiss Date'), |
|
78 |
('Personne promo String'), |
|
79 |
# real relations |
|
80 |
('Personne travaille Societe'), |
|
81 |
('Personne evaluee Note'), |
|
82 |
('Societe evaluee Note'), |
|
83 |
('Personne concerne Affaire'), |
|
84 |
('Personne concerne Societe'), |
|
6861
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
85 |
('Affaire concerne Societe'), |
0 | 86 |
) |
87 |
done = {} |
|
88 |
for rel in RELS: |
|
89 |
_from, _type, _to = rel.split() |
|
90 |
if not _type.lower() in done: |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
91 |
schema.add_relation_type(RelationType(_type)) |
0 | 92 |
done[_type.lower()] = True |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
93 |
if _type == 'concerne': |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
94 |
schema.add_relation_def(RelationDefinition(_from, _type, _to, |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
95 |
__permissions__=CONCERNE_PERMISSIONS)) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
96 |
else: |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
97 |
schema.add_relation_def(RelationDefinition(_from, _type, _to)) |
0 | 98 |
|
99 |
class CubicWebSchemaTC(TestCase): |
|
100 |
||
3978
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
101 |
def test_rql_constraints_inheritance(self): |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
102 |
# isinstance(cstr, RQLVocabularyConstraint) |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
103 |
# -> expected to return RQLVocabularyConstraint and RQLConstraint |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
104 |
# instances but not RQLUniqueConstraint |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
105 |
# |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
106 |
# isinstance(cstr, RQLConstraint) |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
107 |
# -> expected to return RQLConstraint instances but not |
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
108 |
# RRQLVocabularyConstraint and QLUniqueConstraint |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
109 |
self.assertFalse(issubclass(RQLUniqueConstraint, RQLVocabularyConstraint)) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
110 |
self.assertFalse(issubclass(RQLUniqueConstraint, RQLConstraint)) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
111 |
self.assertTrue(issubclass(RQLConstraint, RQLVocabularyConstraint)) |
3978
2c95e3033f64
finish yesterday work on rql constraints:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3899
diff
changeset
|
112 |
|
0 | 113 |
def test_entity_perms(self): |
114 |
self.assertEqual(eperson.get_groups('read'), set(('managers', 'users', 'guests'))) |
|
115 |
self.assertEqual(eperson.get_groups('update'), set(('managers', 'owners',))) |
|
116 |
self.assertEqual(eperson.get_groups('delete'), set(('managers', 'owners'))) |
|
117 |
self.assertEqual(eperson.get_groups('add'), set(('managers',))) |
|
118 |
self.assertEqual([str(e) for e in eperson.get_rqlexprs('add')], |
|
119 |
['Any X WHERE X travaille S, S owned_by U, X eid %(x)s, U eid %(u)s']) |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
120 |
eperson.set_action_permissions('read', ('managers',)) |
0 | 121 |
self.assertEqual(eperson.get_groups('read'), set(('managers',))) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
122 |
|
0 | 123 |
def test_relation_perms(self): |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
124 |
rconcerne = schema.rschema('concerne').rdef('Personne', 'Societe') |
0 | 125 |
self.assertEqual(rconcerne.get_groups('read'), set(('managers', 'users', 'guests'))) |
126 |
self.assertEqual(rconcerne.get_groups('delete'), set(('managers',))) |
|
127 |
self.assertEqual(rconcerne.get_groups('add'), set(('managers', ))) |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
128 |
rconcerne.set_action_permissions('read', ('managers',)) |
0 | 129 |
self.assertEqual(rconcerne.get_groups('read'), set(('managers',))) |
130 |
self.assertEqual([str(e) for e in rconcerne.get_rqlexprs('add')], |
|
3899
78a2c8e7eef5
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
131 |
['Any S,U WHERE U has_update_permission S, S eid %(s)s, U eid %(u)s']) |
0 | 132 |
|
133 |
def test_erqlexpression(self): |
|
134 |
self.assertRaises(RQLSyntaxError, ERQLExpression, '1') |
|
135 |
expr = ERQLExpression('X travaille S, S owned_by U') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
136 |
self.assertEqual(str(expr), 'Any X WHERE X travaille S, S owned_by U, X eid %(x)s, U eid %(u)s') |
9280
bae0caa8477a
[schema] edit syntax tree instead of playing with strings for RQLExpressions
Julien Cristau <julien.cristau@logilab.fr>
parents:
9214
diff
changeset
|
137 |
expr = ERQLExpression('X foo S, S bar U, X baz XE, S quux SE HAVING XE > SE') |
bae0caa8477a
[schema] edit syntax tree instead of playing with strings for RQLExpressions
Julien Cristau <julien.cristau@logilab.fr>
parents:
9214
diff
changeset
|
138 |
self.assertEqual(str(expr), 'Any X WHERE X foo S, S bar U, X baz XE, S quux SE, X eid %(x)s, U eid %(u)s HAVING XE > SE') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
139 |
|
0 | 140 |
def test_rrqlexpression(self): |
141 |
self.assertRaises(Exception, RRQLExpression, '1') |
|
142 |
self.assertRaises(RQLSyntaxError, RRQLExpression, 'O X Y') |
|
143 |
expr = RRQLExpression('U has_update_permission O') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
144 |
self.assertEqual(str(expr), 'Any O,U WHERE U has_update_permission O, O eid %(o)s, U eid %(u)s') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
145 |
|
0 | 146 |
loader = CubicWebSchemaLoader() |
6640
4c4616c02f69
[test] more cwd independant tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
147 |
config = TestConfiguration('data', apphome=DATADIR) |
0 | 148 |
config.bootstrap_cubes() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
149 |
|
2926
4484387ed012
when adding/removing cubes, we should add/remove entity types in correct order if one inherits from another
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
150 |
class SchemaReaderClassTest(TestCase): |
4484387ed012
when adding/removing cubes, we should add/remove entity types in correct order if one inherits from another
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
151 |
|
4484387ed012
when adding/removing cubes, we should add/remove entity types in correct order if one inherits from another
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
152 |
def test_order_eschemas(self): |
4484387ed012
when adding/removing cubes, we should add/remove entity types in correct order if one inherits from another
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
153 |
schema = loader.load(config) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
154 |
self.assertEqual(order_eschemas([schema['Note'], schema['SubNote']]), |
2926
4484387ed012
when adding/removing cubes, we should add/remove entity types in correct order if one inherits from another
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
155 |
[schema['Note'], schema['SubNote']]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
156 |
self.assertEqual(order_eschemas([schema['SubNote'], schema['Note']]), |
2926
4484387ed012
when adding/removing cubes, we should add/remove entity types in correct order if one inherits from another
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
157 |
[schema['Note'], schema['SubNote']]) |
0 | 158 |
|
159 |
def test_knownValues_load_schema(self): |
|
160 |
schema = loader.load(config) |
|
161 |
self.assert_(isinstance(schema, CubicWebSchema)) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
162 |
self.assertEqual(schema.name, 'data') |
6415 | 163 |
entities = sorted([str(e) for e in schema.entities()]) |
9214
be05b42b4825
Do not use cubicweb-card in rest_path tests
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9158
diff
changeset
|
164 |
expected_entities = ['Ami', 'BaseTransition', 'BigInt', 'Bookmark', 'Boolean', 'Bytes', 'Card', |
0 | 165 |
'Date', 'Datetime', 'Decimal', |
9956
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9952
diff
changeset
|
166 |
'CWCache', 'CWComputedRType', 'CWConstraint', |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9952
diff
changeset
|
167 |
'CWConstraintType', 'CWDataImport', 'CWEType', |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9952
diff
changeset
|
168 |
'CWAttribute', 'CWGroup', 'EmailAddress', |
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9952
diff
changeset
|
169 |
'CWRelation', 'CWPermission', 'CWProperty', 'CWRType', |
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6910
diff
changeset
|
170 |
'CWSource', 'CWSourceHostConfig', 'CWSourceSchemaConfig', |
6306
e6557be1127e
[test] fix test broken by introduction of CWUniqueTogetherConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6117
diff
changeset
|
171 |
'CWUniqueTogetherConstraint', 'CWUser', |
5563
26e242ba3da5
with cw 3.9, no more Image type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
172 |
'ExternalUri', 'File', 'Float', 'Int', 'Interval', 'Note', |
7426
254bc099db1a
[test] update test broken by previous commit
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7166
diff
changeset
|
173 |
'Password', 'Personne', 'Produit', |
9978
8f4b15e5b300
[entities] cw_rest_attr_info() should only consider required attributes (closes #3766717)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9711
diff
changeset
|
174 |
'RQLExpression', 'Reference', |
7426
254bc099db1a
[test] update test broken by previous commit
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7166
diff
changeset
|
175 |
'Service', 'Societe', 'State', 'StateFull', 'String', 'SubNote', 'SubWorkflowExitPoint', |
7166
dde161937d3e
[time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7152
diff
changeset
|
176 |
'Tag', 'TZDatetime', 'TZTime', 'Time', 'Transition', 'TrInfo', |
7426
254bc099db1a
[test] update test broken by previous commit
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7166
diff
changeset
|
177 |
'Usine', |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
178 |
'Workflow', 'WorkflowTransition'] |
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6910
diff
changeset
|
179 |
self.assertListEqual(sorted(expected_entities), entities) |
6415 | 180 |
relations = sorted([str(r) for r in schema.relations()]) |
8005
a3e06bed6b18
fix broken tests (at least by #1800002)
Florent Cayré <florent.cayre@gmail.com>
parents:
7995
diff
changeset
|
181 |
expected_relations = ['actionnaire', 'add_permission', 'address', 'alias', 'allowed_transition', 'associe', |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
182 |
'bookmarked_by', 'by_transition', |
0 | 183 |
|
3204
0b766b8a13e1
#370578: change EmailAddress identical_to/canonical to prefered_form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2943
diff
changeset
|
184 |
'cardinality', 'comment', 'comment_format', |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6415
diff
changeset
|
185 |
'composite', 'condition', 'config', 'connait', |
6306
e6557be1127e
[test] fix test broken by introduction of CWUniqueTogetherConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6117
diff
changeset
|
186 |
'constrained_by', 'constraint_of', |
8005
a3e06bed6b18
fix broken tests (at least by #1800002)
Florent Cayré <florent.cayre@gmail.com>
parents:
7995
diff
changeset
|
187 |
'content', 'content_format', 'contrat_exclusif', |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6415
diff
changeset
|
188 |
'created_by', 'creation_date', 'cstrtype', 'custom_workflow', |
7995
9a9f35ef418c
Record a log of datafeed source imports (closes #2026097)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7981
diff
changeset
|
189 |
'cwuri', 'cw_for_source', 'cw_import_of', 'cw_host_config_of', 'cw_schema', 'cw_source', |
0 | 190 |
|
3587 | 191 |
'data', 'data_encoding', 'data_format', 'data_name', 'default_workflow', 'defaultval', 'delete_permission', |
8005
a3e06bed6b18
fix broken tests (at least by #1800002)
Florent Cayré <florent.cayre@gmail.com>
parents:
7995
diff
changeset
|
192 |
'description', 'description_format', 'destination_state', 'dirige', |
0 | 193 |
|
9984
793377697c81
merge 3.18.6 into 3.19
Julien Cristau <julien.cristau@logilab.fr>
parents:
9978
diff
changeset
|
194 |
'ean', 'ecrit_par', 'eid', 'end_timestamp', 'evaluee', 'expression', 'exprtype', 'extra_props', |
0 | 195 |
|
9965
a8769b752299
[CWEP002] Account for attribute formula in schema bootstrap
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9956
diff
changeset
|
196 |
'fabrique_par', 'final', 'firstname', 'for_user', 'formula', 'fournit', |
0 | 197 |
'from_entity', 'from_state', 'fulltext_container', 'fulltextindexed', |
8005
a3e06bed6b18
fix broken tests (at least by #1800002)
Florent Cayré <florent.cayre@gmail.com>
parents:
7995
diff
changeset
|
198 |
|
7981
676fd5b30c6a
[test] fix failure introduced by localperms cube introduction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7962
diff
changeset
|
199 |
'has_group_permission', 'has_text', |
7957
5da7ede69063
[test]Â fix some failures recently introduced
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
200 |
'identity', 'in_group', 'in_state', 'in_synchronization', 'indexed', |
0 | 201 |
'initial_state', 'inlined', 'internationalizable', 'is', 'is_instance_of', |
202 |
||
7995
9a9f35ef418c
Record a log of datafeed source imports (closes #2026097)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7981
diff
changeset
|
203 |
'label', 'last_login_time', 'latest_retrieval', 'lieu', 'log', 'login', |
0 | 204 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6415
diff
changeset
|
205 |
'mainvars', 'match_host', 'modification_date', |
0 | 206 |
|
750
89e997bc2bf1
update test for new test schema
sylvain.thenault@logilab.fr
parents:
624
diff
changeset
|
207 |
'name', 'nom', |
0 | 208 |
|
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6910
diff
changeset
|
209 |
'options', 'ordernum', 'owned_by', |
0 | 210 |
|
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6944
diff
changeset
|
211 |
'parser', 'path', 'pkey', 'prefered_form', 'prenom', 'primary_email', |
0 | 212 |
|
9956
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9952
diff
changeset
|
213 |
'read_permission', 'relation_type', 'relations', 'require_group', 'rule', |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
214 |
|
7995
9a9f35ef418c
Record a log of datafeed source imports (closes #2026097)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7981
diff
changeset
|
215 |
'specializes', 'start_timestamp', 'state_of', 'status', 'subworkflow', 'subworkflow_exit', 'subworkflow_state', 'surname', 'symmetric', 'synopsis', |
0 | 216 |
|
750
89e997bc2bf1
update test for new test schema
sylvain.thenault@logilab.fr
parents:
624
diff
changeset
|
217 |
'tags', 'timestamp', 'title', 'to_entity', 'to_state', 'transition_of', 'travaille', 'type', |
0 | 218 |
|
6957
ffda12be2e9f
[repository] #1460066: backport datafeed cube as cubicweb source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6944
diff
changeset
|
219 |
'upassword', 'update_permission', 'url', 'uri', 'use_email', |
0 | 220 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
221 |
'value', |
0 | 222 |
|
6768
b75f688bded7
fix unittest broken by TrInfo schema change
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6640
diff
changeset
|
223 |
'wf_info_for', 'wikiid', 'workflow_of', 'tr_count'] |
9158
08d8fba05854
[test] make unittest_schema.py compatible with cubicweb-file 0.14
David Douard <david.douard@logilab.fr>
parents:
8945
diff
changeset
|
224 |
if config.cube_version('file') >= (1, 14, 0): |
08d8fba05854
[test] make unittest_schema.py compatible with cubicweb-file 0.14
David Douard <david.douard@logilab.fr>
parents:
8945
diff
changeset
|
225 |
expected_relations.append('data_sha1hex') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
226 |
|
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6910
diff
changeset
|
227 |
self.assertListEqual(sorted(expected_relations), relations) |
0 | 228 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
985
diff
changeset
|
229 |
eschema = schema.eschema('CWUser') |
0 | 230 |
rels = sorted(str(r) for r in eschema.subject_relations()) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6415
diff
changeset
|
231 |
self.assertListEqual(rels, ['created_by', 'creation_date', 'custom_workflow', |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6415
diff
changeset
|
232 |
'cw_source', 'cwuri', 'eid', |
7795
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
233 |
'evaluee', 'firstname', 'has_group_permission', |
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
234 |
'has_text', 'identity', |
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
235 |
'in_group', 'in_state', 'is', |
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
236 |
'is_instance_of', 'last_login_time', |
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
237 |
'login', 'modification_date', 'owned_by', |
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
238 |
'primary_email', 'surname', 'upassword', |
b8027b317d1c
[test]Â fix some tests broken since localperms cube extraction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
239 |
'use_email']) |
0 | 240 |
rels = sorted(r.type for r in eschema.object_relations()) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
241 |
self.assertListEqual(rels, ['bookmarked_by', 'created_by', 'for_user', |
0 | 242 |
'identity', 'owned_by', 'wf_info_for']) |
243 |
rschema = schema.rschema('relation_type') |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
244 |
properties = rschema.rdef('CWAttribute', 'CWRType') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
245 |
self.assertEqual(properties.cardinality, '1*') |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
246 |
constraints = properties.constraints |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
247 |
self.assertEqual(len(constraints), 1, constraints) |
0 | 248 |
constraint = constraints[0] |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
249 |
self.assertTrue(isinstance(constraint, RQLConstraint)) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7642
diff
changeset
|
250 |
self.assertEqual(constraint.expression, 'O final TRUE') |
0 | 251 |
|
252 |
def test_fulltext_container(self): |
|
253 |
schema = loader.load(config) |
|
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9640
diff
changeset
|
254 |
self.assertIn('has_text', schema['CWUser'].subject_relations()) |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
255 |
self.assertNotIn('has_text', schema['EmailAddress'].subject_relations()) |
0 | 256 |
|
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
257 |
def test_permission_settings(self): |
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
258 |
schema = loader.load(config) |
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
259 |
aschema = schema['TrInfo'].rdef('comment') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
260 |
self.assertEqual(aschema.get_groups('read'), |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
261 |
set(('managers', 'users', 'guests'))) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
262 |
self.assertEqual(aschema.get_rqlexprs('read'), |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
263 |
()) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
264 |
self.assertEqual(aschema.get_groups('update'), |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
265 |
set(('managers',))) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
266 |
self.assertEqual([x.expression for x in aschema.get_rqlexprs('update')], |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
267 |
['U has_update_permission X']) |
0 | 268 |
|
7440
539de926ec9d
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7426
diff
changeset
|
269 |
def test_nonregr_allowed_type_names(self): |
539de926ec9d
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7426
diff
changeset
|
270 |
schema = CubicWebSchema('Test Schema') |
539de926ec9d
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7426
diff
changeset
|
271 |
schema.add_entity_type(EntityType('NaN')) |
539de926ec9d
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7426
diff
changeset
|
272 |
|
8167
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
273 |
def test_relation_perm_overriding(self): |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
274 |
loader = CubicWebSchemaLoader() |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
275 |
config = TestConfiguration('data', apphome=join(dirname(__file__), 'data_schemareader')) |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
276 |
config.bootstrap_cubes() |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
277 |
schema = loader.load(config) |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
278 |
self.assertEqual(schema['in_group'].rdefs.values()[0].permissions, |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
279 |
{'read': ('managers',), |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
280 |
'add': ('managers',), |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
281 |
'delete': ('managers',)}) |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
282 |
self.assertEqual(schema['cw_for_source'].rdefs.values()[0].permissions, |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
283 |
{'read': ('managers', 'users'), |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
284 |
'add': ('managers',), |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
285 |
'delete': ('managers',)}) |
41ec579e27c4
[test] test/demonstrate relation permissions overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8005
diff
changeset
|
286 |
|
9966
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
287 |
def test_computed_attribute(self): |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
288 |
"""Check schema finalization for computed attributes.""" |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
289 |
class Person(EntityType): |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
290 |
salary = Int() |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
291 |
|
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
292 |
class works_for(RelationDefinition): |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
293 |
subject = 'Person' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
294 |
object = 'Company' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
295 |
cardinality = '?*' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
296 |
|
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
297 |
class Company(EntityType): |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
298 |
total_salary = Int(formula='Any SUM(SA) GROUPBY X WHERE ' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
299 |
'P works_for X, P salary SA') |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
300 |
good_schema = build_schema_from_namespace(vars().items()) |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
301 |
|
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
302 |
class Company(EntityType): |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
303 |
total_salary = String(formula='Any SUM(SA) GROUPBY X WHERE ' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
304 |
'P works_for X, P salary SA') |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
305 |
|
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
306 |
with self.assertRaises(BadSchemaDefinition) as exc: |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
307 |
bad_schema = build_schema_from_namespace(vars().items()) |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
308 |
|
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
309 |
self.assertEqual(str(exc.exception), |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
310 |
'computed attribute total_salary on Company: ' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
311 |
'computed attribute type (Int) mismatch with ' |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
312 |
'specified type (String)') |
6c2d57d1b6de
[CWEP002] Add schema finalization checks for computed attributes
Laura Médioni <laura.medioni@logilab.fr>
parents:
9965
diff
changeset
|
313 |
|
7440
539de926ec9d
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7426
diff
changeset
|
314 |
|
9952
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
315 |
class SchemaReaderComputedRelationAndAttributesTest(TestCase): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
316 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
317 |
def test_infer_computed_relation(self): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
318 |
class Person(EntityType): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
319 |
name = String() |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
320 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
321 |
class Company(EntityType): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
322 |
name = String() |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
323 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
324 |
class Service(EntityType): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
325 |
name = String() |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
326 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
327 |
class works_for(RelationDefinition): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
328 |
subject = 'Person' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
329 |
object = 'Company' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
330 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
331 |
class produce(RelationDefinition): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
332 |
subject = ('Person', 'Company') |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
333 |
object = 'Service' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
334 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
335 |
class achete(RelationDefinition): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
336 |
subject = 'Person' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
337 |
object = 'Service' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
338 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
339 |
class produces_and_buys(ComputedRelation): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
340 |
rule = 'S produce O, S achete O' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
341 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
342 |
class produces_and_buys2(ComputedRelation): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
343 |
rule = 'S works_for SO, SO produce O' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
344 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
345 |
class reproduce(ComputedRelation): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
346 |
rule = 'S produce O' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
347 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
348 |
schema = build_schema_from_namespace(vars().items()) |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
349 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
350 |
# check object/subject type |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
351 |
self.assertEqual([('Person','Service')], |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
352 |
schema['produces_and_buys'].rdefs.keys()) |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
353 |
self.assertEqual([('Person','Service')], |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
354 |
schema['produces_and_buys2'].rdefs.keys()) |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
355 |
self.assertEqual([('Company', 'Service'), ('Person', 'Service')], |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
356 |
schema['reproduce'].rdefs.keys()) |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
357 |
# check relations as marked infered |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
358 |
self.assertTrue( |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
359 |
schema['produces_and_buys'].rdefs[('Person','Service')].infered) |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
360 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
361 |
del schema |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
362 |
class autoname(ComputedRelation): |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
363 |
rule = 'S produce X, X name O' |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
364 |
|
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
365 |
with self.assertRaises(BadSchemaDefinition) as cm: |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
366 |
build_schema_from_namespace(vars().items()) |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
367 |
self.assertEqual(str(cm.exception), 'computed relations cannot be final') |
0f3f965b6365
[CWEP002] Add schema finalization checks for computed relations (rules)
Lea Capgen <lea.capgen@logilab.fr>, Sylvain Thénault <sylvain.thenault@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9711
diff
changeset
|
368 |
|
7440
539de926ec9d
[test] fix failure introduced by 1719eab69551: the regexp should be fixed, not the error message
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7426
diff
changeset
|
369 |
|
6861
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
370 |
class BadSchemaTC(TestCase): |
0 | 371 |
def setUp(self): |
372 |
self.loader = CubicWebSchemaLoader() |
|
373 |
self.loader.defined = {} |
|
951 | 374 |
self.loader.loaded_files = [] |
4469
310b5f01c982
need post_build_callbacks attribute with earlier yams version
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
375 |
self.loader.post_build_callbacks = [] |
0 | 376 |
|
377 |
def _test(self, schemafile, msg): |
|
378 |
self.loader.handle_file(join(DATADIR, schemafile)) |
|
7469
f8c983afbf8e
[test] update cubicweb/test/unittest_schema.py (to follow yams#.....)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7460
diff
changeset
|
379 |
sch = self.loader.schemacls('toto') |
6796
e70ca9abfc51
[unittest2] update to unittest2 assertRaises api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6768
diff
changeset
|
380 |
with self.assertRaises(BadSchemaDefinition) as cm: |
7469
f8c983afbf8e
[test] update cubicweb/test/unittest_schema.py (to follow yams#.....)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7460
diff
changeset
|
381 |
fill_schema(sch, self.loader.defined, False) |
6796
e70ca9abfc51
[unittest2] update to unittest2 assertRaises api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6768
diff
changeset
|
382 |
self.assertEqual(str(cm.exception), msg) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
383 |
|
6861
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
384 |
def test_lowered_etype(self): |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
385 |
self._test('lowered_etype.py', |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
386 |
"'my_etype' is not a valid name for an entity type. It should " |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
387 |
"start with an upper cased letter and be followed by at least " |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
388 |
"a lower cased letter") |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
389 |
|
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
390 |
def test_uppered_rtype(self): |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
391 |
self._test('uppered_rtype.py', |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
392 |
"'ARelation' is not a valid name for a relation type. It should be lower cased") |
9d4e11d6e783
[schema] ease understanding of schema naming error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
393 |
|
0 | 394 |
def test_rrqlexpr_on_etype(self): |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
395 |
self._test('rrqlexpr_on_eetype.py', |
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
396 |
"can't use RRQLExpression on ToTo, use an ERQLExpression") |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
397 |
|
0 | 398 |
def test_erqlexpr_on_rtype(self): |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
399 |
self._test('erqlexpr_on_ertype.py', |
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
400 |
"can't use ERQLExpression on relation ToTo toto TuTu, use a RRQLExpression") |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
401 |
|
0 | 402 |
def test_rqlexpr_on_rtype_read(self): |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
403 |
self._test('rqlexpr_on_ertype_read.py', |
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
404 |
"can't use rql expression for read permission of relation ToTo toto TuTu") |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
405 |
|
0 | 406 |
def test_rrqlexpr_on_attr(self): |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
407 |
self._test('rrqlexpr_on_attr.py', |
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
408 |
"can't use RRQLExpression on attribute ToTo.attr[String], use an ERQLExpression") |
0 | 409 |
|
410 |
||
411 |
class NormalizeExpressionTC(TestCase): |
|
412 |
||
413 |
def test(self): |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
414 |
self.assertEqual(normalize_expression('X bla Y,Y blur Z , Z zigoulou X '), |
0 | 415 |
'X bla Y, Y blur Z, Z zigoulou X') |
416 |
||
9640
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
417 |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
418 |
class RQLExpressionTC(TestCase): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
419 |
def test_comparison(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6306
diff
changeset
|
420 |
self.assertEqual(ERQLExpression('X is CWUser', 'X', 0), |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
421 |
ERQLExpression('X is CWUser', 'X', 0)) |
6415 | 422 |
self.assertNotEqual(ERQLExpression('X is CWUser', 'X', 0), |
5179
f08943f22334
[schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4611
diff
changeset
|
423 |
ERQLExpression('X is CWGroup', 'X', 0)) |
4181 | 424 |
|
9640
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
425 |
|
4132
440d383367eb
fix mainvars detection bug with EXISTS (paren, actually)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
426 |
class GuessRrqlExprMainVarsTC(TestCase): |
440d383367eb
fix mainvars detection bug with EXISTS (paren, actually)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
427 |
def test_exists(self): |
7603
1302aa6ba4da
[schema / rql] fix mainvars of RRQLExpression with parens
Florent Cayré <florent.cayre@gmail.com>
parents:
7426
diff
changeset
|
428 |
mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3, C concerns S)')) |
1302aa6ba4da
[schema / rql] fix mainvars of RRQLExpression with parens
Florent Cayré <florent.cayre@gmail.com>
parents:
7426
diff
changeset
|
429 |
self.assertEqual(mainvars, set(['S', 'O'])) |
4132
440d383367eb
fix mainvars detection bug with EXISTS (paren, actually)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3978
diff
changeset
|
430 |
|
4181 | 431 |
|
7640
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
432 |
class RQLConstraintTC(CubicWebTC): |
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
433 |
def test_user_constraint(self): |
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
434 |
cstr = RQLConstraint('U identity O') |
9640
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
435 |
with self.admin_access.repo_cnx() as cnx: |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
436 |
anoneid = cnx.execute('Any X WHERE X login "anon"')[0][0] |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
437 |
self.assertRaises(ValidationError, |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
438 |
cstr.repo_check, cnx, 1, 'rel', anoneid) |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
439 |
self.assertEqual(cstr.repo_check(cnx, 1, cnx.user.eid), |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
440 |
None) # no validation error, constraint checked |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
441 |
|
7640
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
442 |
|
8336
7ccd4367ee1c
[workflow] set default test/plain option for workflow default comment (closes #993083)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8167
diff
changeset
|
443 |
class WorkflowShemaTC(CubicWebTC): |
7ccd4367ee1c
[workflow] set default test/plain option for workflow default comment (closes #993083)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8167
diff
changeset
|
444 |
def test_trinfo_default_format(self): |
9640
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
445 |
with self.admin_access.web_request() as req: |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
446 |
tr = req.user.cw_adapt_to('IWorkflowable').fire_transition('deactivate') |
26ea1c4387bf
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9547
diff
changeset
|
447 |
self.assertEqual(tr.comment_format, 'text/plain') |
7640
85ebdbbcb321
[schema] closes #1816439: RQLConstraint does not take variable U into account
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7603
diff
changeset
|
448 |
|
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
449 |
|
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
450 |
class CompositeSchemaTC(CubicWebTC): |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
451 |
composites = { |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
452 |
'BaseTransition': [('condition', 'BaseTransition', 'RQLExpression', 'subject')], |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
453 |
'CWAttribute': [('add_permission', 'CWAttribute', 'RQLExpression', 'subject'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
454 |
('constrained_by', 'CWAttribute', 'CWConstraint', 'subject'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
455 |
('read_permission', 'CWAttribute', 'RQLExpression', 'subject'), |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
456 |
('update_permission', 'CWAttribute', 'RQLExpression', 'subject')], |
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
457 |
'CWEType': [('add_permission', 'CWEType', 'RQLExpression', 'subject'), |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
458 |
('constraint_of', 'CWUniqueTogetherConstraint', 'CWEType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
459 |
('cw_schema', 'CWSourceSchemaConfig', 'CWEType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
460 |
('delete_permission', 'CWEType', 'RQLExpression', 'subject'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
461 |
('from_entity', 'CWAttribute', 'CWEType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
462 |
('from_entity', 'CWRelation', 'CWEType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
463 |
('read_permission', 'CWEType', 'RQLExpression', 'subject'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
464 |
('to_entity', 'CWAttribute', 'CWEType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
465 |
('to_entity', 'CWRelation', 'CWEType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
466 |
('update_permission', 'CWEType', 'RQLExpression', 'subject')], |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
467 |
'CWRType': [('cw_schema', 'CWSourceSchemaConfig', 'CWRType', 'object'), |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
468 |
('relation_type', 'CWAttribute', 'CWRType', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
469 |
('relation_type', 'CWRelation', 'CWRType', 'object')], |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
470 |
'CWRelation': [('add_permission', 'CWRelation', 'RQLExpression', 'subject'), |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
471 |
('constrained_by', 'CWRelation', 'CWConstraint', 'subject'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
472 |
('cw_schema', 'CWSourceSchemaConfig', 'CWRelation', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
473 |
('delete_permission', 'CWRelation', 'RQLExpression', 'subject'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
474 |
('read_permission', 'CWRelation', 'RQLExpression', 'subject')], |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
475 |
'CWSource': [('cw_for_source', 'CWSourceSchemaConfig', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
476 |
('cw_host_config_of', 'CWSourceHostConfig', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
477 |
('cw_import_of', 'CWDataImport', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
478 |
('cw_source', 'Ami', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
479 |
('cw_source', 'BaseTransition', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
480 |
('cw_source', 'Bookmark', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
481 |
('cw_source', 'CWAttribute', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
482 |
('cw_source', 'CWCache', 'CWSource', 'object'), |
9956
19a683a0047c
[CWEP002] properly handle serialization of computed relations
Lea Capgen <lea.capgen@logilab.fr>
parents:
9952
diff
changeset
|
483 |
('cw_source', 'CWComputedRType', 'CWSource', 'object'), |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
484 |
('cw_source', 'CWConstraint', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
485 |
('cw_source', 'CWConstraintType', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
486 |
('cw_source', 'CWDataImport', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
487 |
('cw_source', 'CWEType', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
488 |
('cw_source', 'CWGroup', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
489 |
('cw_source', 'CWPermission', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
490 |
('cw_source', 'CWProperty', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
491 |
('cw_source', 'CWRType', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
492 |
('cw_source', 'CWRelation', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
493 |
('cw_source', 'CWSource', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
494 |
('cw_source', 'CWSourceHostConfig', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
495 |
('cw_source', 'CWSourceSchemaConfig', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
496 |
('cw_source', 'CWUniqueTogetherConstraint', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
497 |
('cw_source', 'CWUser', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
498 |
('cw_source', 'Card', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
499 |
('cw_source', 'EmailAddress', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
500 |
('cw_source', 'ExternalUri', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
501 |
('cw_source', 'File', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
502 |
('cw_source', 'Note', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
503 |
('cw_source', 'Personne', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
504 |
('cw_source', 'Produit', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
505 |
('cw_source', 'RQLExpression', 'CWSource', 'object'), |
9978
8f4b15e5b300
[entities] cw_rest_attr_info() should only consider required attributes (closes #3766717)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9711
diff
changeset
|
506 |
('cw_source', 'Reference', 'CWSource', 'object'), |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
507 |
('cw_source', 'Service', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
508 |
('cw_source', 'Societe', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
509 |
('cw_source', 'State', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
510 |
('cw_source', 'StateFull', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
511 |
('cw_source', 'SubNote', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
512 |
('cw_source', 'SubWorkflowExitPoint', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
513 |
('cw_source', 'Tag', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
514 |
('cw_source', 'TrInfo', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
515 |
('cw_source', 'Transition', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
516 |
('cw_source', 'Usine', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
517 |
('cw_source', 'Workflow', 'CWSource', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
518 |
('cw_source', 'WorkflowTransition', 'CWSource', 'object')], |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
519 |
'CWUser': [('for_user', 'CWProperty', 'CWUser', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
520 |
('use_email', 'CWUser', 'EmailAddress', 'subject'), |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
521 |
('wf_info_for', 'TrInfo', 'CWUser', 'object')], |
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
522 |
'StateFull': [('wf_info_for', 'TrInfo', 'StateFull', 'object')], |
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
523 |
'Transition': [('condition', 'Transition', 'RQLExpression', 'subject')], |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
524 |
'Workflow': [('state_of', 'State', 'Workflow', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
525 |
('transition_of', 'BaseTransition', 'Workflow', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
526 |
('transition_of', 'Transition', 'Workflow', 'object'), |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
527 |
('transition_of', 'WorkflowTransition', 'Workflow', 'object')], |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
528 |
'WorkflowTransition': [('condition', 'WorkflowTransition', 'RQLExpression', 'subject'), |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
529 |
('subworkflow_exit', 'WorkflowTransition', 'SubWorkflowExitPoint', 'subject')] |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
530 |
} |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
531 |
|
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
532 |
def test_composite_entities(self): |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
533 |
schema = self.vreg.schema |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
534 |
self.assertEqual(sorted(self.composites), |
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
535 |
[eschema.type for eschema in sorted(schema.entities()) |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
536 |
if eschema.is_composite]) |
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
537 |
for etype in self.composites: |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
538 |
self.set_description('composite rdefs for %s' % etype) |
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
539 |
yield self.assertEqual, self.composites[etype], \ |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
540 |
sorted([(r.rtype.type, r.subject.type, r.object.type, role) |
9711
59616edc20d7
[schema] fix buggy composite_rdef_roles and associated test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9675
diff
changeset
|
541 |
for r, role in sorted(schema[etype].composite_rdef_roles)]) |
9547
43aace16a953
[schema] add composite handling helpers on EntitySchema (related to #3463112)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9280
diff
changeset
|
542 |
|
9967
e65873ad0371
[CWEP002] Add support for computed attribute synchronization
Sylvain Thénault
parents:
9966
diff
changeset
|
543 |
|
0 | 544 |
if __name__ == '__main__': |
545 |
unittest_main() |