test/data/schema.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 07 Jul 2011 18:20:23 +0200
changeset 7632 3c9dfc6e820b
parent 7425 7e9d1d6fcba7
child 7973 64639bc94e25
permissions -rw-r--r--
[book] fix some rest/sphinx errors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7153
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
     1
# copyright 2003-2011 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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
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: 4467
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
2615
1ea41b7c0836 F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    18
6908
f07dc0e8948d fix #1452413 : is_in_state selector does not match initial state of an entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5424
diff changeset
    19
from yams.buildobjs import (EntityType, String, SubjectRelation,
f07dc0e8948d fix #1452413 : is_in_state selector does not match initial state of an entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5424
diff changeset
    20
                            RelationDefinition)
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    21
7153
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
    22
from cubicweb.schema import (WorkflowableEntityType,
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
    23
                             RQLConstraint, RQLVocabularyConstraint)
2615
1ea41b7c0836 F [dialog] offer to create backup. refactor to use l.c.shellutils.ASK
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    24
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    25
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    26
class Personne(EntityType):
748
eec752381926 unittest_entity ok
sylvain.thenault@logilab.fr
parents: 744
diff changeset
    27
    nom = String(required=True)
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    28
    prenom = String()
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    29
    type = String()
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    30
    travaille = SubjectRelation('Societe')
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    31
    evaluee = SubjectRelation(('Note', 'Personne'))
7153
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
    32
    connait = SubjectRelation(
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
    33
        'Personne', symmetric=True,
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
    34
        constraints=[
7df83a6d17c0 [entity vocabulary] fix unrelated rql generation to skip rql constraints that don't make sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6919
diff changeset
    35
            RQLConstraint('NOT S identity O'),
7154
5e2f93b88d86 [entity vocabulary] refactor unrelated rql to allow usage of RQLRewriter to insert schema constraints. Closes #1561806
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7153
diff changeset
    36
            # conflicting constraints, see cw_unrelated_rql tests in
5e2f93b88d86 [entity vocabulary] refactor unrelated rql to allow usage of RQLRewriter to insert schema constraints. Closes #1561806
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7153
diff changeset
    37
            # unittest_entity.py
5e2f93b88d86 [entity vocabulary] refactor unrelated rql to allow usage of RQLRewriter to insert schema constraints. Closes #1561806
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7153
diff changeset
    38
            RQLVocabularyConstraint('NOT (S connait P, P nom "toto")'),
5e2f93b88d86 [entity vocabulary] refactor unrelated rql to allow usage of RQLRewriter to insert schema constraints. Closes #1561806
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7153
diff changeset
    39
            RQLVocabularyConstraint('S travaille P, P nom "tutu"')])
1476
f94b41709ce6 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    40
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    41
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    42
class Societe(EntityType):
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    43
    nom = String()
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    44
    evaluee = SubjectRelation('Note')
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    45
    fournit = SubjectRelation(('Service', 'Produit'), cardinality='1*')
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    46
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    47
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    48
class Service(EntityType):
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    49
    fabrique_par = SubjectRelation('Personne', cardinality='1*')
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    50
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    51
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    52
class Produit(EntityType):
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    53
    fabrique_par = SubjectRelation('Usine', cardinality='1*')
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    54
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    55
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    56
class Usine(EntityType):
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    57
    lieu = String(required=True)
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    58
1476
f94b41709ce6 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    59
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    60
class Note(EntityType):
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    61
    type = String()
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    62
    ecrit_par = SubjectRelation('Personne')
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    63
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    64
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    65
class SubNote(Note):
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    66
    __specializes_schema__ = True
750
89e997bc2bf1 update test for new test schema
sylvain.thenault@logilab.fr
parents: 748
diff changeset
    67
    description = String()
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    68
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    69
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    70
class tags(RelationDefinition):
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    71
    subject = 'Tag'
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    72
    object = ('Personne', 'Note')
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    73
7425
7e9d1d6fcba7 [entity fetch_attrs] remove ambiguous relations on different etypes from fetched attrs or it may produce wrong related results; closes #1700896
Florent Cayré <florent.cayre@gmail.com>
parents: 7154
diff changeset
    74
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    75
class evaluee(RelationDefinition):
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 750
diff changeset
    76
    subject = 'CWUser'
744
4da6e0f4df2a test upgrade
sylvain.thenault@logilab.fr
parents:
diff changeset
    77
    object = 'Note'
6908
f07dc0e8948d fix #1452413 : is_in_state selector does not match initial state of an entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5424
diff changeset
    78
6919
8fd6921f3e7c [selectors] modify workflow selectors: is_in_state, on_transition
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6908
diff changeset
    79
6908
f07dc0e8948d fix #1452413 : is_in_state selector does not match initial state of an entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5424
diff changeset
    80
class StateFull(WorkflowableEntityType):
f07dc0e8948d fix #1452413 : is_in_state selector does not match initial state of an entity
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5424
diff changeset
    81
    name = String()