[server/test] do not depend on third party cubes
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 19 Mar 2019 14:26:51 +0100
changeset 12515 2d43c8b30ef0
parent 12514 eac7f5b20f9f
child 12516 ec089debcd45
[server/test] do not depend on third party cubes Drop requirement of basket, card, comment, file, localperms and tag cubes for cubicweb.server tests. Copy needed part of schema, entities, views, hooks into the cubicweb/server/test/data directory (which is included in PYTHONPATH for CubicWebTC tests). For migration tests which use different "datapath", use symlinks to have dependent cubes importables.
cubicweb/server/test/data-migractions/cubicweb_basket
cubicweb/server/test/data-migractions/cubicweb_card
cubicweb/server/test/data-migractions/cubicweb_comment
cubicweb/server/test/data-migractions/cubicweb_file
cubicweb/server/test/data-migractions/cubicweb_localperms
cubicweb/server/test/data-migractions/cubicweb_tag
cubicweb/server/test/data-migractions/migratedapp/cubicweb_basket
cubicweb/server/test/data-migractions/migratedapp/cubicweb_card
cubicweb/server/test/data-migractions/migratedapp/cubicweb_comment
cubicweb/server/test/data-migractions/migratedapp/cubicweb_file
cubicweb/server/test/data-migractions/migratedapp/cubicweb_localperms
cubicweb/server/test/data-migractions/migratedapp/cubicweb_tag
cubicweb/server/test/data/cubicweb_basket/__init__.py
cubicweb/server/test/data/cubicweb_basket/__pkginfo__.py
cubicweb/server/test/data/cubicweb_basket/schema.py
cubicweb/server/test/data/cubicweb_card/__init__.py
cubicweb/server/test/data/cubicweb_card/__pkginfo__.py
cubicweb/server/test/data/cubicweb_card/schema.py
cubicweb/server/test/data/cubicweb_comment/__init__.py
cubicweb/server/test/data/cubicweb_comment/__pkginfo__.py
cubicweb/server/test/data/cubicweb_comment/schema.py
cubicweb/server/test/data/cubicweb_file/__init__.py
cubicweb/server/test/data/cubicweb_file/__pkginfo__.py
cubicweb/server/test/data/cubicweb_file/schema.py
cubicweb/server/test/data/cubicweb_localperms/__init__.py
cubicweb/server/test/data/cubicweb_localperms/__pkginfo__.py
cubicweb/server/test/data/cubicweb_localperms/schema.py
cubicweb/server/test/data/cubicweb_tag/__init__.py
cubicweb/server/test/data/cubicweb_tag/__pkginfo__.py
cubicweb/server/test/data/cubicweb_tag/schema.py
requirements/test-server.txt
tox.ini
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/cubicweb_basket	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../data/cubicweb_basket
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/cubicweb_card	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../data/cubicweb_card
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/cubicweb_comment	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../data/cubicweb_comment
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/cubicweb_file	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../data/cubicweb_file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/cubicweb_localperms	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../data/cubicweb_localperms
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/cubicweb_tag	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../data/cubicweb_tag
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/migratedapp/cubicweb_basket	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../../data/cubicweb_basket
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/migratedapp/cubicweb_card	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../../data/cubicweb_card
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/migratedapp/cubicweb_comment	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../../data/cubicweb_comment
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/migratedapp/cubicweb_file	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../../data/cubicweb_file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/migratedapp/cubicweb_localperms	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../../data/cubicweb_localperms
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data-migractions/migratedapp/cubicweb_tag	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,1 @@
+../../data/cubicweb_tag
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_basket/__pkginfo__.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,2 @@
+numversion = (1, 2, 3)
+version = "1.2.3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_basket/schema.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,21 @@
+from yams.buildobjs import EntityType, RelationDefinition, String, RichString
+from cubicweb.schema import ERQLExpression
+
+
+class Basket(EntityType):
+    """a basket contains a set of other entities"""
+    __permissions__ = {
+        'read':   ('managers', ERQLExpression('X owned_by U'),),
+        'add':    ('managers', 'users',),
+        'delete': ('managers', 'owners',),
+        'update': ('managers', 'owners',),
+        }
+
+    name = String(required=True, indexed=True, internationalizable=True,
+                  maxsize=128)
+    description = RichString(fulltextindexed=True)
+
+
+class in_basket(RelationDefinition):
+    subject = '*'
+    object = 'Basket'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_card/__pkginfo__.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,2 @@
+numversion = (1, 2, 3)
+version = "1.2.3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_card/schema.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,17 @@
+from yams.buildobjs import EntityType, String, RichString
+
+
+class Card(EntityType):
+    __permissions__ = {
+        'read':   ('managers', 'users', 'guests'),
+        'add':    ('managers', 'users'),
+        'delete': ('managers', 'owners'),
+        'update': ('managers', 'owners',),
+        }
+
+    title = String(required=True, fulltextindexed=True, maxsize=256)
+    synopsis = String(fulltextindexed=True, maxsize=512,
+                      description=("an abstract for this card"))
+    content = RichString(fulltextindexed=True, internationalizable=True,
+                         default_format='text/rest')
+    wikiid = String(maxsize=64, unique=True)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_comment/__pkginfo__.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,2 @@
+numversion = (1, 2, 3)
+version = "1.2.3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_comment/schema.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,26 @@
+from yams.buildobjs import (EntityType, RelationType, SubjectRelation,
+                            RichString)
+from cubicweb.schema import RRQLExpression
+
+
+class Comment(EntityType):
+    """a comment is a reply about another entity"""
+    __permissions__ = {
+        'read':   ('managers', 'users', 'guests',),
+        'add':    ('managers', 'users',),
+        'delete': ('managers', 'owners',),
+        'update': ('managers', 'owners',),
+        }
+    content = RichString(required=True, fulltextindexed=True)
+    comments = SubjectRelation('Comment', cardinality='1*', composite='object')
+
+
+class comments(RelationType):
+    __permissions__ = {
+        'read':   ('managers', 'users', 'guests'),
+        'add':    ('managers', 'users',),
+        'delete': ('managers', RRQLExpression('S owned_by U'),),
+        }
+    inlined = True
+    composite = 'object'
+    cardinality = '1*'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_file/__pkginfo__.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,2 @@
+numversion = (1, 2, 3)
+version = "1.2.3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_file/schema.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,27 @@
+from yams.buildobjs import EntityType, String, Bytes, RichString
+
+
+class File(EntityType):
+    """a downloadable file which may contains binary data"""
+    title = String(fulltextindexed=True, maxsize=256)
+    data = Bytes(required=True, description='file to upload')
+    data_format = String(
+        required=True, maxsize=128,
+        description=('MIME type of the file. Should be dynamically set '
+                     'at upload time.'))
+    data_encoding = String(
+        maxsize=32,
+        description=('encoding of the file when it applies (e.g. text). '
+                     'Should be dynamically set at upload time.'))
+    data_name = String(
+        required=True, fulltextindexed=True,
+        description=('name of the file. Should be dynamically set '
+                     'at upload time.'))
+    data_hash = String(
+        maxsize=256,  # max len of currently available hash alg + prefix is 140
+        description=('hash of the file. May be set at upload time.'),
+        __permissions__={'read': ('managers', 'users', 'guests'),
+                         'add': (),
+                         'update': ()})
+    description = RichString(fulltextindexed=True, internationalizable=True,
+                             default_format='text/rest')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_localperms/__pkginfo__.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,2 @@
+numversion = (1, 2, 3)
+version = "1.2.3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_localperms/schema.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,42 @@
+from yams.buildobjs import EntityType, RelationType, RelationDefinition, String
+from cubicweb.schema import PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS
+
+
+class CWPermission(EntityType):
+    """entity type that may be used to construct some advanced security
+    configuration
+    """
+    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
+
+    name = String(required=True, indexed=True, internationalizable=True,
+                  maxsize=100, description=(
+                      'name or identifier of the permission'))
+    label = String(required=True, internationalizable=True, maxsize=100,
+                   description=('distinct label to distinguate between other '
+                                'permission entity of the same name'))
+
+
+class granted_permission(RelationType):
+    """explicitly granted permission on an entity"""
+    __permissions__ = PUB_SYSTEM_REL_PERMS
+    # XXX cardinality = '*1'
+
+
+class require_permission(RelationType):
+    __permissions__ = PUB_SYSTEM_REL_PERMS
+
+
+class require_group(RelationDefinition):
+    """groups to which the permission is granted"""
+    __permissions__ = PUB_SYSTEM_REL_PERMS
+    subject = 'CWPermission'
+    object = 'CWGroup'
+
+
+class has_group_permission(RelationDefinition):
+    """short cut relation for 'U in_group G, P require_group G' for efficiency
+    reason. This relation is set automatically, you should not set this.
+    """
+    __permissions__ = PUB_SYSTEM_REL_PERMS
+    subject = 'CWUser'
+    object = 'CWPermission'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_tag/__pkginfo__.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,2 @@
+numversion = (1, 2, 3)
+version = "1.2.3"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cubicweb/server/test/data/cubicweb_tag/schema.py	Tue Mar 19 14:26:51 2019 +0100
@@ -0,0 +1,17 @@
+from yams.buildobjs import EntityType, String, SubjectRelation, RelationType
+
+
+class Tag(EntityType):
+    """tags are used by users to mark entities.
+    When you include the Tag entity, all application specific entities
+    may then be tagged using the "tags" relation.
+    """
+    name = String(required=True, fulltextindexed=True, unique=True,
+                  maxsize=128)
+    # when using this component, add the Tag tag X relation for each type that
+    # should be taggeable
+    tags = SubjectRelation('Tag', description="tagged objects")
+
+
+class tags(RelationType):
+    """indicates that an entity is classified by a given tag"""
--- a/requirements/test-server.txt	Fri Mar 15 15:51:27 2019 +0100
+++ b/requirements/test-server.txt	Tue Mar 19 14:26:51 2019 +0100
@@ -1,9 +1,3 @@
 mock
 psycopg2
 ldap3 < 2
-cubicweb-basket
-cubicweb-card
-cubicweb-comment
-cubicweb-file >= 2.2.2
-cubicweb-localperms
-cubicweb-tag
--- a/tox.ini	Fri Mar 15 15:51:27 2019 +0100
+++ b/tox.ini	Tue Mar 19 14:26:51 2019 +0100
@@ -43,7 +43,7 @@
   {envpython} -m check_manifest {toxinidir} \
 # ignore symlinks that are not recognized by check-manifest, see
 # https://github.com/mgedmin/check-manifest/issues/69
-    --ignore cubicweb/devtools/test/data/cubes/i18ntestcube*,cubicweb/test/data/legacy_cubes*
+    --ignore cubicweb/devtools/test/data/cubes/i18ntestcube*,cubicweb/test/data/legacy_cubes*,cubicweb/server/test/data-migractions/cubicweb_*,cubicweb/server/test/data-migractions/migratedapp/cubicweb_*
 
 [pytest]
 python_files = *test_*.py