author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 28 May 2014 17:57:40 +0200 | |
changeset 9783 | 59c582ce68c8 |
parent 9675 | 8aabfefc8a81 |
child 9787 | ae624d86c652 |
permissions | -rw-r--r-- |
9588
fe267b7336f3
[migration] always rebuild infered relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9395
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
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:
4774
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6595
00cd0b273cf5
[test] fix test to follow recent changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
18 |
"""unit tests for module cubicweb.server.migractions""" |
0 | 19 |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
20 |
from datetime import date |
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2591
diff
changeset
|
21 |
from os.path import join |
0 | 22 |
|
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
23 |
from logilab.common.testlib import TestCase, unittest_main, Tags, tag |
0 | 24 |
|
6292
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
25 |
from yams.constraints import UniqueConstraint |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
26 |
|
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
27 |
from cubicweb import ConfigurationError, ValidationError |
4689
4eb1f4490538
[test] skipping versions checking during test is enough, no need for monkey patch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4681
diff
changeset
|
28 |
from cubicweb.devtools.testlib import CubicWebTC |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
29 |
from cubicweb.schema import CubicWebSchemaLoader |
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
30 |
from cubicweb.server.sqlutils import SQL_PREFIX |
0 | 31 |
from cubicweb.server.migractions import * |
32 |
||
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
33 |
import cubicweb.devtools |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
34 |
|
4774
89a7555020ba
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4763
diff
changeset
|
35 |
migrschema = None |
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6635
diff
changeset
|
36 |
def tearDownModule(*args): |
4774
89a7555020ba
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4763
diff
changeset
|
37 |
global migrschema |
89a7555020ba
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4763
diff
changeset
|
38 |
del migrschema |
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
39 |
if hasattr(MigrationCommandsTC, 'origschema'): |
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
40 |
del MigrationCommandsTC.origschema |
1787 | 41 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
42 |
class MigrationCommandsTC(CubicWebTC): |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
43 |
|
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
44 |
configcls = cubicweb.devtools.TestServerConfiguration |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
45 |
|
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
46 |
tags = CubicWebTC.tags | Tags(('server', 'migration', 'migractions')) |
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
47 |
|
9043
97c3bb9a7c99
[testlib] move repo and related attribute back on Instance instead of Class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8947
diff
changeset
|
48 |
def _init_repo(self): |
97c3bb9a7c99
[testlib] move repo and related attribute back on Instance instead of Class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8947
diff
changeset
|
49 |
super(MigrationCommandsTC, self)._init_repo() |
4681
5f72584ab1d7
[test] cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4635
diff
changeset
|
50 |
# we have to read schema from the database to get eid for schema entities |
9043
97c3bb9a7c99
[testlib] move repo and related attribute back on Instance instead of Class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8947
diff
changeset
|
51 |
self.repo.set_schema(self.repo.deserialize_schema(), resetvreg=False) |
8947
3bbd416b09ec
[repo] straightforward bootstrap sequence. Closes #2841188
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8942
diff
changeset
|
52 |
# hack to read the schema from data/migrschema |
9043
97c3bb9a7c99
[testlib] move repo and related attribute back on Instance instead of Class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8947
diff
changeset
|
53 |
config = self.config |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
54 |
config.appid = join('data', 'migratedapp') |
9043
97c3bb9a7c99
[testlib] move repo and related attribute back on Instance instead of Class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8947
diff
changeset
|
55 |
config._apphome = self.datapath('migratedapp') |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
56 |
global migrschema |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
57 |
migrschema = config.load_schema() |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
58 |
config.appid = 'data' |
9043
97c3bb9a7c99
[testlib] move repo and related attribute back on Instance instead of Class
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8947
diff
changeset
|
59 |
config._apphome = self.datadir |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
60 |
assert 'Folder' in migrschema |
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
61 |
|
0 | 62 |
def setUp(self): |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
63 |
CubicWebTC.setUp(self) |
0 | 64 |
self.mh = ServerMigrationHelper(self.repo.config, migrschema, |
65 |
repo=self.repo, cnx=self.cnx, |
|
66 |
interactive=False) |
|
9556
12ee310541bb
[server/migractions] finish migration to repoapi objects
Julien Cristau <julien.cristau@logilab.fr>
parents:
9402
diff
changeset
|
67 |
assert self.cnx is self.mh.cnx |
972 | 68 |
assert self.session is self.mh.session, (self.session.id, self.mh.session.id) |
1787 | 69 |
|
6795
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
70 |
def tearDown(self): |
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
71 |
CubicWebTC.tearDown(self) |
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
72 |
self.repo.vreg['etypes'].clear_caches() |
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
73 |
|
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
74 |
def test_add_attribute_bool(self): |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
75 |
self.assertNotIn('yesno', self.schema) |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
76 |
self.session.create_entity('Note') |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
77 |
self.commit() |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
78 |
self.mh.cmd_add_attribute('Note', 'yesno') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
79 |
self.assertIn('yesno', self.schema) |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
80 |
self.assertEqual(self.schema['yesno'].subjects(), ('Note',)) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
81 |
self.assertEqual(self.schema['yesno'].objects(), ('Boolean',)) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
82 |
self.assertEqual(self.schema['Note'].default('yesno'), False) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
83 |
# test default value set on existing entities |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
84 |
note = self.session.execute('Note X').get_entity(0, 0) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
85 |
self.assertEqual(note.yesno, False) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
86 |
# test default value set for next entities |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
87 |
self.assertEqual(self.session.create_entity('Note').yesno, False) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
88 |
self.mh.rollback() |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
89 |
|
0 | 90 |
def test_add_attribute_int(self): |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
91 |
self.assertNotIn('whatever', self.schema) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
92 |
self.session.create_entity('Note') |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
93 |
self.session.commit(free_cnxset=False) |
3134
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
94 |
orderdict = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, ' |
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
95 |
'RDEF relation_type RT, RDEF ordernum O, RT name RTN')) |
0 | 96 |
self.mh.cmd_add_attribute('Note', 'whatever') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
97 |
self.assertIn('whatever', self.schema) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
98 |
self.assertEqual(self.schema['whatever'].subjects(), ('Note',)) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
99 |
self.assertEqual(self.schema['whatever'].objects(), ('Int',)) |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
100 |
self.assertEqual(self.schema['Note'].default('whatever'), 0) |
6795
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
101 |
# test default value set on existing entities |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
102 |
note = self.session.execute('Note X').get_entity(0, 0) |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
103 |
self.assertIsInstance(note.whatever, int) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
104 |
self.assertEqual(note.whatever, 0) |
6795
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
105 |
# test default value set for next entities |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
106 |
self.assertEqual(self.session.create_entity('Note').whatever, 0) |
6795
f29d24c3d687
[server test] fix test inter-dependancy issue
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6790
diff
changeset
|
107 |
# test attribute order |
3134
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
108 |
orderdict2 = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, ' |
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
109 |
'RDEF relation_type RT, RDEF ordernum O, RT name RTN')) |
4100 | 110 |
whateverorder = migrschema['whatever'].rdef('Note', 'Int').order |
3134
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
111 |
for k, v in orderdict.iteritems(): |
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
112 |
if v >= whateverorder: |
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
113 |
orderdict[k] = v+1 |
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
114 |
orderdict['whatever'] = whateverorder |
6369
a151453dc564
[test] more update to unittest2 api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
115 |
self.assertDictEqual(orderdict, orderdict2) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
116 |
#self.assertEqual([r.type for r in self.schema['Note'].ordered_relations()], |
0 | 117 |
# ['modification_date', 'creation_date', 'owned_by', |
118 |
# 'eid', 'ecrit_par', 'inline1', 'date', 'type', |
|
3134
3cda74b5534c
update test to avoid failure due to migration schema changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3126
diff
changeset
|
119 |
# 'whatever', 'date', 'in_basket']) |
0 | 120 |
# NB: commit instead of rollback make following test fail with py2.5 |
121 |
# this sounds like a pysqlite/2.5 bug (the same eid is affected to |
|
122 |
# two different entities) |
|
123 |
self.mh.rollback() |
|
124 |
||
125 |
def test_add_attribute_varchar(self): |
|
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
126 |
self.assertNotIn('whatever', self.schema) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
127 |
self.session.create_entity('Note') |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
128 |
self.session.commit(free_cnxset=False) |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
129 |
self.assertNotIn('shortpara', self.schema) |
0 | 130 |
self.mh.cmd_add_attribute('Note', 'shortpara') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
131 |
self.assertIn('shortpara', self.schema) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
132 |
self.assertEqual(self.schema['shortpara'].subjects(), ('Note', )) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
133 |
self.assertEqual(self.schema['shortpara'].objects(), ('String', )) |
0 | 134 |
# test created column is actually a varchar(64) |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
135 |
notesql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' and name='%sNote'" % SQL_PREFIX)[0][0] |
0 | 136 |
fields = dict(x.strip().split()[:2] for x in notesql.split('(', 1)[1].rsplit(')', 1)[0].split(',')) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
137 |
self.assertEqual(fields['%sshortpara' % SQL_PREFIX], 'varchar(64)') |
6790
f4f67ea5436a
[schema migration] add a test to ensure default value are considered
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
138 |
# test default value set on existing entities |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
139 |
self.assertEqual(self.session.execute('Note X').get_entity(0, 0).shortpara, 'hop') |
6790
f4f67ea5436a
[schema migration] add a test to ensure default value are considered
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
140 |
# test default value set for next entities |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
141 |
self.assertEqual(self.session.create_entity('Note').shortpara, 'hop') |
0 | 142 |
self.mh.rollback() |
1787 | 143 |
|
0 | 144 |
def test_add_datetime_with_default_value_attribute(self): |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
145 |
self.assertNotIn('mydate', self.schema) |
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
146 |
self.assertNotIn('oldstyledefaultdate', self.schema) |
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
147 |
self.assertNotIn('newstyledefaultdate', self.schema) |
0 | 148 |
self.mh.cmd_add_attribute('Note', 'mydate') |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
149 |
self.mh.cmd_add_attribute('Note', 'oldstyledefaultdate') |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
150 |
self.mh.cmd_add_attribute('Note', 'newstyledefaultdate') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
151 |
self.assertIn('mydate', self.schema) |
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
152 |
self.assertIn('oldstyledefaultdate', self.schema) |
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
153 |
self.assertIn('newstyledefaultdate', self.schema) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
154 |
self.assertEqual(self.schema['mydate'].subjects(), ('Note', )) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
155 |
self.assertEqual(self.schema['mydate'].objects(), ('Date', )) |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
156 |
testdate = date(2005, 12, 13) |
0 | 157 |
eid1 = self.mh.rqlexec('INSERT Note N')[0][0] |
158 |
eid2 = self.mh.rqlexec('INSERT Note N: N mydate %(mydate)s', {'mydate' : testdate})[0][0] |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4774
diff
changeset
|
159 |
d1 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid1})[0][0] |
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4774
diff
changeset
|
160 |
d2 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid2})[0][0] |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
161 |
d3 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X oldstyledefaultdate D', {'x': eid1})[0][0] |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
162 |
d4 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X newstyledefaultdate D', {'x': eid1})[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
163 |
self.assertEqual(d1, date.today()) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
164 |
self.assertEqual(d2, testdate) |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
165 |
myfavoritedate = date(2013, 1, 1) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
166 |
self.assertEqual(d3, myfavoritedate) |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
9273
diff
changeset
|
167 |
self.assertEqual(d4, myfavoritedate) |
0 | 168 |
self.mh.rollback() |
1787 | 169 |
|
6292
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
170 |
def test_drop_chosen_constraints_ctxmanager(self): |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
171 |
with self.mh.cmd_dropped_constraints('Note', 'unique_id', UniqueConstraint): |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
172 |
self.mh.cmd_add_attribute('Note', 'unique_id') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
173 |
# make sure the maxsize constraint is not dropped |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
174 |
self.assertRaises(ValidationError, |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
175 |
self.mh.rqlexec, |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
176 |
'INSERT Note N: N unique_id "xyz"') |
6417
d2361abe8505
[test] fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6370
diff
changeset
|
177 |
self.mh.rollback() |
6292
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
178 |
# make sure the unique constraint is dropped |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
179 |
self.mh.rqlexec('INSERT Note N: N unique_id "x"') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
180 |
self.mh.rqlexec('INSERT Note N: N unique_id "x"') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
181 |
self.mh.rqlexec('DELETE Note N') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
182 |
self.mh.rollback() |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
183 |
|
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
184 |
def test_drop_required_ctxmanager(self): |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
185 |
with self.mh.cmd_dropped_constraints('Note', 'unique_id', cstrtype=None, |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
186 |
droprequired=True): |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
187 |
self.mh.cmd_add_attribute('Note', 'unique_id') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
188 |
self.mh.rqlexec('INSERT Note N') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
189 |
# make sure the required=True was restored |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
190 |
self.assertRaises(ValidationError, self.mh.rqlexec, 'INSERT Note N') |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
191 |
self.mh.rollback() |
054fa36060d5
[migractions] add a dropped_constraints() migration command
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6208
diff
changeset
|
192 |
|
0 | 193 |
def test_rename_attribute(self): |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
194 |
self.assertNotIn('civility', self.schema) |
0 | 195 |
eid1 = self.mh.rqlexec('INSERT Personne X: X nom "lui", X sexe "M"')[0][0] |
196 |
eid2 = self.mh.rqlexec('INSERT Personne X: X nom "l\'autre", X sexe NULL')[0][0] |
|
197 |
self.mh.cmd_rename_attribute('Personne', 'sexe', 'civility') |
|
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
198 |
self.assertNotIn('sexe', self.schema) |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
199 |
self.assertIn('civility', self.schema) |
0 | 200 |
# test data has been backported |
201 |
c1 = self.mh.rqlexec('Any C WHERE X eid %s, X civility C' % eid1)[0][0] |
|
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
202 |
self.assertEqual(c1, 'M') |
0 | 203 |
c2 = self.mh.rqlexec('Any C WHERE X eid %s, X civility C' % eid2)[0][0] |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
204 |
self.assertEqual(c2, None) |
0 | 205 |
|
206 |
||
207 |
def test_workflow_actions(self): |
|
6816
f61de39cd396
[wf migration] allow to deactivate assertion on wfable entity to quick-fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6815
diff
changeset
|
208 |
wf = self.mh.cmd_add_workflow(u'foo', ('Personne', 'Email'), |
f61de39cd396
[wf migration] allow to deactivate assertion on wfable entity to quick-fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6815
diff
changeset
|
209 |
ensure_workflowable=False) |
0 | 210 |
for etype in ('Personne', 'Email'): |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2903
diff
changeset
|
211 |
s1 = self.mh.rqlexec('Any N WHERE WF workflow_of ET, ET name "%s", WF name N' % |
0 | 212 |
etype)[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
213 |
self.assertEqual(s1, "foo") |
2943
77622caef9bd
[schema] default_workflow_of more naturally expressed as default_workflow
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2931
diff
changeset
|
214 |
s1 = self.mh.rqlexec('Any N WHERE ET default_workflow WF, ET name "%s", WF name N' % |
0 | 215 |
etype)[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
216 |
self.assertEqual(s1, "foo") |
1787 | 217 |
|
0 | 218 |
def test_add_entity_type(self): |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
219 |
self.assertNotIn('Folder2', self.schema) |
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
220 |
self.assertNotIn('filed_under2', self.schema) |
0 | 221 |
self.mh.cmd_add_entity_type('Folder2') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
222 |
self.assertIn('Folder2', self.schema) |
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
223 |
self.assertIn('Old', self.schema) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
224 |
self.assertTrue(self.session.execute('CWEType X WHERE X name "Folder2"')) |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
225 |
self.assertIn('filed_under2', self.schema) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
226 |
self.assertTrue(self.session.execute('CWRType X WHERE X name "filed_under2"')) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
227 |
self.assertEqual(sorted(str(rs) for rs in self.schema['Folder2'].subject_relations()), |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6417
diff
changeset
|
228 |
['created_by', 'creation_date', 'cw_source', 'cwuri', |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
229 |
'description', 'description_format', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
230 |
'eid', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
231 |
'filed_under2', 'has_text', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
232 |
'identity', 'in_basket', 'is', 'is_instance_of', |
0 | 233 |
'modification_date', 'name', 'owned_by']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
234 |
self.assertEqual([str(rs) for rs in self.schema['Folder2'].object_relations()], |
0 | 235 |
['filed_under2', 'identity']) |
8111
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
236 |
# Old will be missing as it has been renamed into 'New' in the migrated |
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
237 |
# schema while New hasn't been added here. |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
238 |
self.assertEqual(sorted(str(e) for e in self.schema['filed_under2'].subjects()), |
8111
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
239 |
sorted(str(e) for e in self.schema.entities() if not e.final and e != 'Old')) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
240 |
self.assertEqual(self.schema['filed_under2'].objects(), ('Folder2',)) |
0 | 241 |
eschema = self.schema.eschema('Folder2') |
4635
44a883148ab4
fix sync_schema_props_perms test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
242 |
for cstr in eschema.rdef('name').constraints: |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
243 |
self.assertTrue(hasattr(cstr, 'eid')) |
0 | 244 |
|
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
245 |
def test_add_drop_entity_type(self): |
0 | 246 |
self.mh.cmd_add_entity_type('Folder2') |
6816
f61de39cd396
[wf migration] allow to deactivate assertion on wfable entity to quick-fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6815
diff
changeset
|
247 |
wf = self.mh.cmd_add_workflow(u'folder2 wf', 'Folder2', |
f61de39cd396
[wf migration] allow to deactivate assertion on wfable entity to quick-fix tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6815
diff
changeset
|
248 |
ensure_workflowable=False) |
3252
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2967
diff
changeset
|
249 |
todo = wf.add_state(u'todo', initial=True) |
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2967
diff
changeset
|
250 |
done = wf.add_state(u'done') |
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2967
diff
changeset
|
251 |
wf.add_transition(u'redoit', done, todo) |
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2967
diff
changeset
|
252 |
wf.add_transition(u'markasdone', todo, done) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
253 |
self.session.commit(free_cnxset=False) |
0 | 254 |
eschema = self.schema.eschema('Folder2') |
255 |
self.mh.cmd_drop_entity_type('Folder2') |
|
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
256 |
self.assertNotIn('Folder2', self.schema) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
257 |
self.assertFalse(self.session.execute('CWEType X WHERE X name "Folder2"')) |
0 | 258 |
# test automatic workflow deletion |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
259 |
self.assertFalse(self.session.execute('Workflow X WHERE NOT X workflow_of ET')) |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
260 |
self.assertFalse(self.session.execute('State X WHERE NOT X state_of WF')) |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
261 |
self.assertFalse(self.session.execute('Transition X WHERE NOT X transition_of WF')) |
0 | 262 |
|
8105
7980b36fb1aa
[schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7791
diff
changeset
|
263 |
def test_rename_entity_type(self): |
7980b36fb1aa
[schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7791
diff
changeset
|
264 |
entity = self.mh.create_entity('Old', name=u'old') |
9663
f512d72a1dc4
[repository]Â 'session' argument is always given to type[_and_source]_from_eid, make it mandatory and simplify code accordingly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9635
diff
changeset
|
265 |
self.repo.type_and_source_from_eid(entity.eid, entity._cw) |
8105
7980b36fb1aa
[schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7791
diff
changeset
|
266 |
self.mh.cmd_rename_entity_type('Old', 'New') |
7980b36fb1aa
[schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7791
diff
changeset
|
267 |
self.mh.cmd_rename_attribute('New', 'name', 'new_name') |
7980b36fb1aa
[schema sync] Update repo._type_source_cache when renaming an entity (closes #2094470)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7791
diff
changeset
|
268 |
|
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
269 |
def test_add_drop_relation_type(self): |
0 | 270 |
self.mh.cmd_add_entity_type('Folder2', auto=False) |
271 |
self.mh.cmd_add_relation_type('filed_under2') |
|
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
272 |
self.assertIn('filed_under2', self.schema) |
8111
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
273 |
# Old will be missing as it has been renamed into 'New' in the migrated |
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
274 |
# schema while New hasn't been added here. |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
275 |
self.assertEqual(sorted(str(e) for e in self.schema['filed_under2'].subjects()), |
8111
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
276 |
sorted(str(e) for e in self.schema.entities() |
d1be698018d2
[server test] Fix tests regression from changeset 7980b36fb1aa
Julien Cristau <julien.cristau@logilab.fr>
parents:
8105
diff
changeset
|
277 |
if not e.final and e != 'Old')) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
278 |
self.assertEqual(self.schema['filed_under2'].objects(), ('Folder2',)) |
0 | 279 |
self.mh.cmd_drop_relation_type('filed_under2') |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
280 |
self.assertNotIn('filed_under2', self.schema) |
0 | 281 |
|
282 |
def test_add_relation_definition_nortype(self): |
|
283 |
self.mh.cmd_add_relation_definition('Personne', 'concerne2', 'Affaire') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
284 |
self.assertEqual(self.schema['concerne2'].subjects(), |
0 | 285 |
('Personne',)) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
286 |
self.assertEqual(self.schema['concerne2'].objects(), |
2745
0dafa29ace1f
[schema migration] test reproducing pb when deleting a relation definition with mandatory card and without removing the associated rtype + fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2744
diff
changeset
|
287 |
('Affaire', )) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
288 |
self.assertEqual(self.schema['concerne2'].rdef('Personne', 'Affaire').cardinality, |
2745
0dafa29ace1f
[schema migration] test reproducing pb when deleting a relation definition with mandatory card and without removing the associated rtype + fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2744
diff
changeset
|
289 |
'1*') |
0dafa29ace1f
[schema migration] test reproducing pb when deleting a relation definition with mandatory card and without removing the associated rtype + fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2744
diff
changeset
|
290 |
self.mh.cmd_add_relation_definition('Personne', 'concerne2', 'Note') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
291 |
self.assertEqual(sorted(self.schema['concerne2'].objects()), ['Affaire', 'Note']) |
3252
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2967
diff
changeset
|
292 |
self.mh.create_entity('Personne', nom=u'tot') |
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2967
diff
changeset
|
293 |
self.mh.create_entity('Affaire') |
2745
0dafa29ace1f
[schema migration] test reproducing pb when deleting a relation definition with mandatory card and without removing the associated rtype + fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2744
diff
changeset
|
294 |
self.mh.rqlexec('SET X concerne2 Y WHERE X is Personne, Y is Affaire') |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
295 |
self.session.commit(free_cnxset=False) |
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
296 |
self.mh.cmd_drop_relation_definition('Personne', 'concerne2', 'Affaire') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
297 |
self.assertIn('concerne2', self.schema) |
2745
0dafa29ace1f
[schema migration] test reproducing pb when deleting a relation definition with mandatory card and without removing the associated rtype + fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2744
diff
changeset
|
298 |
self.mh.cmd_drop_relation_definition('Personne', 'concerne2', 'Note') |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
299 |
self.assertNotIn('concerne2', self.schema) |
0 | 300 |
|
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
301 |
def test_drop_relation_definition_existant_rtype(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
302 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
303 |
['Affaire', 'Personne']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
304 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
305 |
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision']) |
0 | 306 |
self.mh.cmd_drop_relation_definition('Personne', 'concerne', 'Affaire') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
307 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
308 |
['Affaire']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
309 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
310 |
['Division', 'Note', 'Societe', 'SubDivision']) |
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
311 |
self.mh.cmd_add_relation_definition('Personne', 'concerne', 'Affaire') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
312 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
313 |
['Affaire', 'Personne']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
314 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
315 |
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision']) |
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
316 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced types |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
317 |
self.maxeid = self.session.execute('Any MAX(X)')[0][0] |
1787 | 318 |
|
0 | 319 |
def test_drop_relation_definition_with_specialization(self): |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
320 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
321 |
['Affaire', 'Personne']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
322 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
323 |
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision']) |
0 | 324 |
self.mh.cmd_drop_relation_definition('Affaire', 'concerne', 'Societe') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
325 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
326 |
['Affaire', 'Personne']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
327 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
328 |
['Affaire', 'Note']) |
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
329 |
self.mh.cmd_add_relation_definition('Affaire', 'concerne', 'Societe') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
330 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
331 |
['Affaire', 'Personne']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
332 |
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].objects()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
333 |
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision']) |
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
334 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced types |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
335 |
self.maxeid = self.session.execute('Any MAX(X)')[0][0] |
0 | 336 |
|
337 |
def test_rename_relation(self): |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
338 |
self.skipTest('implement me') |
0 | 339 |
|
340 |
def test_change_relation_props_non_final(self): |
|
341 |
rschema = self.schema['concerne'] |
|
4100 | 342 |
card = rschema.rdef('Affaire', 'Societe').cardinality |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
343 |
self.assertEqual(card, '**') |
0 | 344 |
try: |
345 |
self.mh.cmd_change_relation_props('Affaire', 'concerne', 'Societe', |
|
346 |
cardinality='?*') |
|
4100 | 347 |
card = rschema.rdef('Affaire', 'Societe').cardinality |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
348 |
self.assertEqual(card, '?*') |
0 | 349 |
finally: |
350 |
self.mh.cmd_change_relation_props('Affaire', 'concerne', 'Societe', |
|
351 |
cardinality='**') |
|
1787 | 352 |
|
0 | 353 |
def test_change_relation_props_final(self): |
354 |
rschema = self.schema['adel'] |
|
4100 | 355 |
card = rschema.rdef('Personne', 'String').fulltextindexed |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
356 |
self.assertEqual(card, False) |
0 | 357 |
try: |
358 |
self.mh.cmd_change_relation_props('Personne', 'adel', 'String', |
|
359 |
fulltextindexed=True) |
|
4100 | 360 |
card = rschema.rdef('Personne', 'String').fulltextindexed |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
361 |
self.assertEqual(card, True) |
0 | 362 |
finally: |
363 |
self.mh.cmd_change_relation_props('Personne', 'adel', 'String', |
|
364 |
fulltextindexed=False) |
|
365 |
||
9565
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
366 |
def test_sync_schema_props_perms_rqlconstraints(self): |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
367 |
# Drop one of the RQLConstraint. |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
368 |
rdef = self.schema['evaluee'].rdefs[('Personne', 'Note')] |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
369 |
oldconstraints = rdef.constraints |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
370 |
self.assertIn('S created_by U', |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
371 |
[cstr.expression for cstr in oldconstraints]) |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
372 |
self.mh.cmd_sync_schema_props_perms('evaluee', commit=True) |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
373 |
newconstraints = rdef.constraints |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
374 |
self.assertNotIn('S created_by U', |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
375 |
[cstr.expression for cstr in newconstraints]) |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
376 |
|
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
377 |
# Drop all RQLConstraint. |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
378 |
rdef = self.schema['travaille'].rdefs[('Personne', 'Societe')] |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
379 |
oldconstraints = rdef.constraints |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
380 |
self.assertEqual(len(oldconstraints), 2) |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
381 |
self.mh.cmd_sync_schema_props_perms('travaille', commit=True) |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
382 |
rdef = self.schema['travaille'].rdefs[('Personne', 'Societe')] |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
383 |
newconstraints = rdef.constraints |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
384 |
self.assertEqual(len(newconstraints), 0) |
fa00fc251d57
[migractions] Better handle removal of RQLConstraint in sync_schema
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9273
diff
changeset
|
385 |
|
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
386 |
@tag('longrun') |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
387 |
def test_sync_schema_props_perms(self): |
2903
043c8fcb3819
[migration] drop rqlcursor
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
388 |
cursor = self.mh.session |
7398
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7242
diff
changeset
|
389 |
cursor.set_cnxset() |
4635
44a883148ab4
fix sync_schema_props_perms test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
390 |
nbrqlexpr_start = cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0] |
4100 | 391 |
migrschema['titre'].rdefs[('Personne', 'String')].order = 7 |
392 |
migrschema['adel'].rdefs[('Personne', 'String')].order = 6 |
|
393 |
migrschema['ass'].rdefs[('Personne', 'String')].order = 5 |
|
0 | 394 |
migrschema['Personne'].description = 'blabla bla' |
1787 | 395 |
migrschema['titre'].description = 'usually a title' |
4103
dc04bede3502
yams api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4100
diff
changeset
|
396 |
migrschema['titre'].rdefs[('Personne', 'String')].description = 'title for this person' |
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4103
diff
changeset
|
397 |
delete_concerne_rqlexpr = self._rrqlexpr_rset('delete', 'concerne') |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4103
diff
changeset
|
398 |
add_concerne_rqlexpr = self._rrqlexpr_rset('add', 'concerne') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6417
diff
changeset
|
399 |
|
1787 | 400 |
self.mh.cmd_sync_schema_props_perms(commit=False) |
401 |
||
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
402 |
self.assertEqual(cursor.execute('Any D WHERE X name "Personne", X description D')[0][0], |
0 | 403 |
'blabla bla') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
404 |
self.assertEqual(cursor.execute('Any D WHERE X name "titre", X description D')[0][0], |
0 | 405 |
'usually a title') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
406 |
self.assertEqual(cursor.execute('Any D WHERE X relation_type RT, RT name "titre",' |
0 | 407 |
'X from_entity FE, FE name "Personne",' |
408 |
'X description D')[0][0], |
|
409 |
'title for this person') |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
410 |
rinorder = [n for n, in cursor.execute( |
9151
78071e41926f
[test] give a non-ambiguous order to sync_schema assertion (closes #3001959)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8947
diff
changeset
|
411 |
'Any N ORDERBY O,N WHERE X is CWAttribute, X relation_type RT, RT name N,' |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
412 |
'X from_entity FE, FE name "Personne",' |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
413 |
'X ordernum O')] |
2930
d7c23b2c7538
some test fixes, more in the 3.5 branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2903
diff
changeset
|
414 |
expected = [u'nom', u'prenom', u'sexe', u'promo', u'ass', u'adel', u'titre', |
9151
78071e41926f
[test] give a non-ambiguous order to sync_schema assertion (closes #3001959)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8947
diff
changeset
|
415 |
u'web', u'tel', u'fax', u'datenaiss', u'test', u'tzdatenaiss', |
7242
7c1937215db9
fix failing test_migration test caused by schema change
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
416 |
u'description', u'firstname', |
7c1937215db9
fix failing test_migration test caused by schema change
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
417 |
u'creation_date', u'cwuri', u'modification_date'] |
9151
78071e41926f
[test] give a non-ambiguous order to sync_schema assertion (closes #3001959)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8947
diff
changeset
|
418 |
self.assertEqual(expected, rinorder) |
0 | 419 |
|
420 |
# test permissions synchronization #################################### |
|
421 |
# new rql expr to add note entity |
|
422 |
eexpr = self._erqlexpr_entity('add', 'Note') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
423 |
self.assertEqual(eexpr.expression, |
0 | 424 |
'X ecrit_part PE, U in_group G, ' |
425 |
'PE require_permission P, P name "add_note", P require_group G') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
426 |
self.assertEqual([et.name for et in eexpr.reverse_add_permission], ['Note']) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
427 |
self.assertEqual(eexpr.reverse_read_permission, ()) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
428 |
self.assertEqual(eexpr.reverse_delete_permission, ()) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
429 |
self.assertEqual(eexpr.reverse_update_permission, ()) |
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
430 |
self.assertTrue(self._rrqlexpr_rset('add', 'para')) |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
431 |
# no rqlexpr to delete para attribute |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
432 |
self.assertFalse(self._rrqlexpr_rset('delete', 'para')) |
1787 | 433 |
# new rql expr to add ecrit_par relation |
0 | 434 |
rexpr = self._rrqlexpr_entity('add', 'ecrit_par') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
435 |
self.assertEqual(rexpr.expression, |
0 | 436 |
'O require_permission P, P name "add_note", ' |
437 |
'U in_group G, P require_group G') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
438 |
self.assertEqual([rdef.rtype.name for rdef in rexpr.reverse_add_permission], ['ecrit_par']) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
439 |
self.assertEqual(rexpr.reverse_read_permission, ()) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
440 |
self.assertEqual(rexpr.reverse_delete_permission, ()) |
0 | 441 |
# no more rqlexpr to delete and add travaille relation |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
442 |
self.assertFalse(self._rrqlexpr_rset('add', 'travaille')) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
443 |
self.assertFalse(self._rrqlexpr_rset('delete', 'travaille')) |
0 | 444 |
# no more rqlexpr to delete and update Societe entity |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
445 |
self.assertFalse(self._erqlexpr_rset('update', 'Societe')) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
446 |
self.assertFalse(self._erqlexpr_rset('delete', 'Societe')) |
0 | 447 |
# no more rqlexpr to read Affaire entity |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
448 |
self.assertFalse(self._erqlexpr_rset('read', 'Affaire')) |
0 | 449 |
# rqlexpr to update Affaire entity has been updated |
450 |
eexpr = self._erqlexpr_entity('update', 'Affaire') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
451 |
self.assertEqual(eexpr.expression, 'X concerne S, S owned_by U') |
0 | 452 |
# no change for rqlexpr to add and delete Affaire entity |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
453 |
self.assertEqual(len(self._erqlexpr_rset('delete', 'Affaire')), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
454 |
self.assertEqual(len(self._erqlexpr_rset('add', 'Affaire')), 1) |
0 | 455 |
# no change for rqlexpr to add and delete concerne relation |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
456 |
self.assertEqual(len(self._rrqlexpr_rset('delete', 'concerne')), len(delete_concerne_rqlexpr)) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
457 |
self.assertEqual(len(self._rrqlexpr_rset('add', 'concerne')), len(add_concerne_rqlexpr)) |
0 | 458 |
# * migrschema involve: |
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
459 |
# * 7 erqlexprs deletions (2 in (Affaire + Societe + Note.para) + 1 Note.something |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
460 |
# * 2 rrqlexprs deletions (travaille) |
0 | 461 |
# * 1 update (Affaire update) |
462 |
# * 2 new (Note add, ecrit_par add) |
|
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
463 |
# * 2 implicit new for attributes (Note.para, Person.test) |
0 | 464 |
# remaining orphan rql expr which should be deleted at commit (composite relation) |
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
465 |
# unattached expressions -> pending deletion on commit |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
466 |
self.assertEqual(cursor.execute('Any COUNT(X) WHERE X is RQLExpression, X exprtype "ERQLExpression",' |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
467 |
'NOT ET1 read_permission X, NOT ET2 add_permission X, ' |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
468 |
'NOT ET3 delete_permission X, NOT ET4 update_permission X')[0][0], |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
469 |
7) |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
470 |
self.assertEqual(cursor.execute('Any COUNT(X) WHERE X is RQLExpression, X exprtype "RRQLExpression",' |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
471 |
'NOT ET1 read_permission X, NOT ET2 add_permission X, ' |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
472 |
'NOT ET3 delete_permission X, NOT ET4 update_permission X')[0][0], |
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
473 |
2) |
0 | 474 |
# finally |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
475 |
self.assertEqual(cursor.execute('Any COUNT(X) WHERE X is RQLExpression')[0][0], |
9395
96dba2efd16d
[hooks/security] provide attribute "add" permission
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
476 |
nbrqlexpr_start + 1 + 2 + 2 + 2) |
6208
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6163
diff
changeset
|
477 |
self.mh.commit() |
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6163
diff
changeset
|
478 |
# unique_together test |
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6163
diff
changeset
|
479 |
self.assertEqual(len(self.schema.eschema('Personne')._unique_together), 1) |
9273
f3795da61959
[test] use assertCountEqual instead of assertItemsEqual
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9151
diff
changeset
|
480 |
self.assertCountEqual(self.schema.eschema('Personne')._unique_together[0], |
6208
07b176640a8c
unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6163
diff
changeset
|
481 |
('nom', 'prenom', 'datenaiss')) |
6635
4e560631f36d
[test] repair test: we now have another unique constraint on CWSourceHostConfig
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6632
diff
changeset
|
482 |
rset = cursor.execute('Any C WHERE C is CWUniqueTogetherConstraint, C constraint_of ET, ET name "Personne"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
483 |
self.assertEqual(len(rset), 1) |
6815
a84190d4e78c
[schema] fix pb with ambiguous relation used within UniqueTogetherConstraint by having CWUniqueTogetherConstraint.relation targeting CWRType instead of CWAttribute/CWRelation. This fixes 3.10.7 migration.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6796
diff
changeset
|
484 |
relations = [r.name for r in rset.get_entity(0, 0).relations] |
9273
f3795da61959
[test] use assertCountEqual instead of assertItemsEqual
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9151
diff
changeset
|
485 |
self.assertCountEqual(relations, ('nom', 'prenom', 'datenaiss')) |
0 | 486 |
|
487 |
def _erqlexpr_rset(self, action, ertype): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
488 |
rql = 'RQLExpression X WHERE ET is CWEType, ET %s_permission X, ET name %%(name)s' % action |
2903
043c8fcb3819
[migration] drop rqlcursor
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
489 |
return self.mh.session.execute(rql, {'name': ertype}) |
0 | 490 |
def _erqlexpr_entity(self, action, ertype): |
491 |
rset = self._erqlexpr_rset(action, ertype) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
492 |
self.assertEqual(len(rset), 1) |
0 | 493 |
return rset.get_entity(0, 0) |
494 |
def _rrqlexpr_rset(self, action, ertype): |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4103
diff
changeset
|
495 |
rql = 'RQLExpression X WHERE RT is CWRType, RDEF %s_permission X, RT name %%(name)s, RDEF relation_type RT' % action |
2903
043c8fcb3819
[migration] drop rqlcursor
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2745
diff
changeset
|
496 |
return self.mh.session.execute(rql, {'name': ertype}) |
0 | 497 |
def _rrqlexpr_entity(self, action, ertype): |
498 |
rset = self._rrqlexpr_rset(action, ertype) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
499 |
self.assertEqual(len(rset), 1) |
0 | 500 |
return rset.get_entity(0, 0) |
1787 | 501 |
|
0 | 502 |
def test_set_size_constraint(self): |
503 |
# existing previous value |
|
504 |
try: |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
505 |
self.mh.cmd_set_size_constraint('CWEType', 'name', 128) |
0 | 506 |
finally: |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
507 |
self.mh.cmd_set_size_constraint('CWEType', 'name', 64) |
0 | 508 |
# non existing previous value |
509 |
try: |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
510 |
self.mh.cmd_set_size_constraint('CWEType', 'description', 256) |
0 | 511 |
finally: |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
512 |
self.mh.cmd_set_size_constraint('CWEType', 'description', None) |
0 | 513 |
|
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
514 |
@tag('longrun') |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
515 |
def test_add_remove_cube_and_deps(self): |
0 | 516 |
cubes = set(self.config.cubes()) |
517 |
schema = self.repo.schema |
|
8696
0bb18407c053
[toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8694
diff
changeset
|
518 |
self.assertEqual(sorted((str(s), str(o)) for s, o in schema['see_also'].rdefs.iterkeys()), |
439 | 519 |
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'), |
520 |
('Bookmark', 'Bookmark'), ('Bookmark', 'Note'), |
|
521 |
('Note', 'Note'), ('Note', 'Bookmark')])) |
|
0 | 522 |
try: |
439 | 523 |
try: |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
524 |
self.mh.cmd_remove_cube('email', removedeps=True) |
439 | 525 |
# file was there because it's an email dependancy, should have been removed |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
526 |
self.assertNotIn('email', self.config.cubes()) |
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
527 |
self.assertNotIn(self.config.cube_dir('email'), self.config.cubes_path()) |
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
528 |
self.assertNotIn('file', self.config.cubes()) |
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
529 |
self.assertNotIn(self.config.cube_dir('file'), self.config.cubes_path()) |
5575
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
530 |
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File', |
439 | 531 |
'sender', 'in_thread', 'reply_to', 'data_format'): |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
532 |
self.assertFalse(ertype in schema, ertype) |
8696
0bb18407c053
[toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8694
diff
changeset
|
533 |
self.assertEqual(sorted(schema['see_also'].rdefs.iterkeys()), |
439 | 534 |
sorted([('Folder', 'Folder'), |
535 |
('Bookmark', 'Bookmark'), |
|
536 |
('Bookmark', 'Note'), |
|
537 |
('Note', 'Note'), |
|
538 |
('Note', 'Bookmark')])) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
539 |
self.assertEqual(sorted(schema['see_also'].subjects()), ['Bookmark', 'Folder', 'Note']) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
540 |
self.assertEqual(sorted(schema['see_also'].objects()), ['Bookmark', 'Folder', 'Note']) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
541 |
self.assertEqual(self.session.execute('Any X WHERE X pkey "system.version.email"').rowcount, 0) |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
542 |
self.assertEqual(self.session.execute('Any X WHERE X pkey "system.version.file"').rowcount, 0) |
439 | 543 |
except : |
544 |
import traceback |
|
545 |
traceback.print_exc() |
|
546 |
raise |
|
0 | 547 |
finally: |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
548 |
self.mh.cmd_add_cube('email') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
549 |
self.assertIn('email', self.config.cubes()) |
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
550 |
self.assertIn(self.config.cube_dir('email'), self.config.cubes_path()) |
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
551 |
self.assertIn('file', self.config.cubes()) |
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
552 |
self.assertIn(self.config.cube_dir('file'), self.config.cubes_path()) |
5575
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
553 |
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File', |
0 | 554 |
'sender', 'in_thread', 'reply_to', 'data_format'): |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
555 |
self.assertTrue(ertype in schema, ertype) |
8696
0bb18407c053
[toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8694
diff
changeset
|
556 |
self.assertEqual(sorted(schema['see_also'].rdefs.iterkeys()), |
439 | 557 |
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'), |
558 |
('Bookmark', 'Bookmark'), |
|
559 |
('Bookmark', 'Note'), |
|
560 |
('Note', 'Note'), |
|
561 |
('Note', 'Bookmark')])) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
562 |
self.assertEqual(sorted(schema['see_also'].subjects()), ['Bookmark', 'EmailThread', 'Folder', 'Note']) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
563 |
self.assertEqual(sorted(schema['see_also'].objects()), ['Bookmark', 'EmailThread', 'Folder', 'Note']) |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
564 |
from cubes.email.__pkginfo__ import version as email_version |
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
565 |
from cubes.file.__pkginfo__ import version as file_version |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
566 |
self.assertEqual(self.session.execute('Any V WHERE X value V, X pkey "system.version.email"')[0][0], |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
567 |
email_version) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
568 |
self.assertEqual(self.session.execute('Any V WHERE X value V, X pkey "system.version.file"')[0][0], |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
569 |
file_version) |
0 | 570 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced |
571 |
# types (and their associated tables!) |
|
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
572 |
self.maxeid = self.session.execute('Any MAX(X)')[0][0] |
0 | 573 |
# why this commit is necessary is unclear to me (though without it |
574 |
# next test may fail complaining of missing tables |
|
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
575 |
self.session.commit(free_cnxset=False) |
972 | 576 |
|
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
577 |
|
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
578 |
@tag('longrun') |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
579 |
def test_add_remove_cube_no_deps(self): |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
580 |
cubes = set(self.config.cubes()) |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
581 |
schema = self.repo.schema |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
582 |
try: |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
583 |
try: |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
584 |
self.mh.cmd_remove_cube('email') |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
585 |
cubes.remove('email') |
9675
8aabfefc8a81
[test] use assertNotIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9674
diff
changeset
|
586 |
self.assertNotIn('email', self.config.cubes()) |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
587 |
self.assertIn('file', self.config.cubes()) |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
588 |
for ertype in ('Email', 'EmailThread', 'EmailPart', |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
589 |
'sender', 'in_thread', 'reply_to'): |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
590 |
self.assertFalse(ertype in schema, ertype) |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
591 |
except : |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
592 |
import traceback |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
593 |
traceback.print_exc() |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
594 |
raise |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
595 |
finally: |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
596 |
self.mh.cmd_add_cube('email') |
9674
96549de9dd70
[test] use assertIn where appropriate
Julien Cristau <julien.cristau@logilab.fr>
parents:
9663
diff
changeset
|
597 |
self.assertIn('email', self.config.cubes()) |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
598 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
599 |
# types (and their associated tables!) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
600 |
self.maxeid = self.session.execute('Any MAX(X)')[0][0] |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
601 |
# why this commit is necessary is unclear to me (though without it |
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
602 |
# next test may fail complaining of missing tables |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
603 |
self.session.commit(free_cnxset=False) |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
604 |
|
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
605 |
def test_remove_dep_cube(self): |
6796
e70ca9abfc51
[unittest2] update to unittest2 assertRaises api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6795
diff
changeset
|
606 |
with self.assertRaises(ConfigurationError) as cm: |
e70ca9abfc51
[unittest2] update to unittest2 assertRaises api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6795
diff
changeset
|
607 |
self.mh.cmd_remove_cube('file') |
e70ca9abfc51
[unittest2] update to unittest2 assertRaises api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6795
diff
changeset
|
608 |
self.assertEqual(str(cm.exception), "can't remove cube file, used as a dependency") |
2124
5a0b02f37b23
set removedeps to False by default, raise an exception instead of a simple assertion for error, more remove_cube tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
609 |
|
7073
4ce9e536dd66
[test] add some tags
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6816
diff
changeset
|
610 |
@tag('longrun') |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
611 |
def test_introduce_base_class(self): |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
612 |
self.mh.cmd_add_entity_type('Para') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
613 |
self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()), |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
614 |
['Note']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
615 |
self.assertEqual(self.schema['Note'].specializes().type, 'Para') |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
616 |
self.mh.cmd_add_entity_type('Text') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
617 |
self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()), |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
618 |
['Note', 'Text']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
619 |
self.assertEqual(self.schema['Text'].specializes().type, 'Para') |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
620 |
# test columns have been actually added |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
621 |
text = self.session.execute('INSERT Text X: X para "hip", X summary "hop", X newattr "momo"').get_entity(0, 0) |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
622 |
note = self.session.execute('INSERT Note X: X para "hip", X shortpara "hop", X newattr "momo", X unique_id "x"').get_entity(0, 0) |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
623 |
aff = self.session.execute('INSERT Affaire X').get_entity(0, 0) |
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
624 |
self.assertTrue(self.session.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4774
diff
changeset
|
625 |
{'x': text.eid, 'y': aff.eid})) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
626 |
self.assertTrue(self.session.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4774
diff
changeset
|
627 |
{'x': note.eid, 'y': aff.eid})) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
628 |
self.assertTrue(self.session.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4774
diff
changeset
|
629 |
{'x': text.eid, 'y': aff.eid})) |
8935
a8a9ba6f4cdd
[server/test] use server config in migration
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
630 |
self.assertTrue(self.session.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4774
diff
changeset
|
631 |
{'x': note.eid, 'y': aff.eid})) |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
632 |
# XXX remove specializes by ourselves, else tearDown fails when removing |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
633 |
# Para because of Note inheritance. This could be fixed by putting the |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
634 |
# MemSchemaCWETypeDel(session, name) operation in the |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
635 |
# after_delete_entity(CWEType) hook, since in that case the MemSchemaSpecializesDel |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
636 |
# operation would be removed before, but I'm not sure this is a desired behaviour. |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
637 |
# |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
638 |
# also we need more tests about introducing/removing base classes or |
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
639 |
# specialization relationship... |
9588
fe267b7336f3
[migration] always rebuild infered relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9395
diff
changeset
|
640 |
self.session.execute('DELETE X specializes Y WHERE Y name "Para"') |
fe267b7336f3
[migration] always rebuild infered relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9395
diff
changeset
|
641 |
self.session.commit(free_cnxset=False) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
642 |
self.assertEqual(sorted(et.type for et in self.schema['Para'].specialized_by()), |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
643 |
[]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
644 |
self.assertEqual(self.schema['Note'].specializes(), None) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6208
diff
changeset
|
645 |
self.assertEqual(self.schema['Text'].specializes(), None) |
2963
12ad88615a12
test and fix migration introducing base classes (w/ regard to yams inheritance)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2930
diff
changeset
|
646 |
|
6163
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
647 |
|
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
648 |
def test_add_symmetric_relation_type(self): |
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
649 |
same_as_sql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' " |
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
650 |
"and name='same_as_relation'") |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
651 |
self.assertFalse(same_as_sql) |
6163
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
652 |
self.mh.cmd_add_relation_type('same_as') |
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
653 |
same_as_sql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' " |
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
654 |
"and name='same_as_relation'") |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
655 |
self.assertTrue(same_as_sql) |
6163
407f54345687
[migration] fix add_relation_type() for symmetric relations
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5575
diff
changeset
|
656 |
|
0 | 657 |
if __name__ == '__main__': |
658 |
unittest_main() |