author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 04 Aug 2009 17:39:02 +0200 | |
changeset 2682 | 0188a4a02403 |
parent 2642 | 2d30de60a8ff |
child 2744 | 66048c669933 |
permissions | -rw-r--r-- |
0 | 1 |
"""unit tests for module cubicweb.server.migractions |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
2 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 3 |
""" |
4 |
||
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
5 |
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
|
6 |
from os.path import join |
0 | 7 |
|
8 |
from logilab.common.testlib import TestCase, unittest_main |
|
9 |
||
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
|
10 |
from cubicweb import ConfigurationError |
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2591
diff
changeset
|
11 |
from cubicweb.devtools.apptest import RepositoryBasedTC, get_versions |
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
|
12 |
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
|
13 |
from cubicweb.server.sqlutils import SQL_PREFIX |
0 | 14 |
from cubicweb.server.repository import Repository |
15 |
from cubicweb.server.migractions import * |
|
16 |
||
17 |
orig_get_versions = Repository.get_versions |
|
18 |
||
19 |
def setup_module(*args): |
|
20 |
Repository.get_versions = get_versions |
|
21 |
||
22 |
def teardown_module(*args): |
|
23 |
Repository.get_versions = orig_get_versions |
|
24 |
||
1787 | 25 |
|
0 | 26 |
class MigrationCommandsTC(RepositoryBasedTC): |
1787 | 27 |
|
0 | 28 |
def setUp(self): |
29 |
if not hasattr(self, '_repo'): |
|
30 |
# first initialization |
|
31 |
repo = self.repo # set by the RepositoryBasedTC metaclass |
|
32 |
# force to read schema from the database |
|
33 |
repo.config._cubes = None |
|
34 |
repo.fill_schema() |
|
35 |
# hack to read the schema from data/migrschema |
|
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2591
diff
changeset
|
36 |
self.repo.config.appid = join('data', 'migratedapp') |
0 | 37 |
global migrschema |
38 |
migrschema = self.repo.config.load_schema() |
|
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2591
diff
changeset
|
39 |
self.repo.config.appid = 'data' |
0 | 40 |
assert 'Folder' in migrschema |
41 |
self.repo.hm.deactivate_verification_hooks() |
|
42 |
RepositoryBasedTC.setUp(self) |
|
43 |
self.mh = ServerMigrationHelper(self.repo.config, migrschema, |
|
44 |
repo=self.repo, cnx=self.cnx, |
|
45 |
interactive=False) |
|
972 | 46 |
assert self.cnx is self.mh._cnx |
47 |
assert self.session is self.mh.session, (self.session.id, self.mh.session.id) |
|
1787 | 48 |
|
0 | 49 |
def test_add_attribute_int(self): |
50 |
self.failIf('whatever' in self.schema) |
|
51 |
paraordernum = self.mh.rqlexec('Any O WHERE X name "Note", RT name "para", RDEF from_entity X, RDEF relation_type RT, RDEF ordernum O')[0][0] |
|
52 |
self.mh.cmd_add_attribute('Note', 'whatever') |
|
53 |
self.failUnless('whatever' in self.schema) |
|
54 |
self.assertEquals(self.schema['whatever'].subjects(), ('Note',)) |
|
55 |
self.assertEquals(self.schema['whatever'].objects(), ('Int',)) |
|
56 |
paraordernum2 = self.mh.rqlexec('Any O WHERE X name "Note", RT name "para", RDEF from_entity X, RDEF relation_type RT, RDEF ordernum O')[0][0] |
|
57 |
self.assertEquals(paraordernum2, paraordernum+1) |
|
58 |
#self.assertEquals([r.type for r in self.schema['Note'].ordered_relations()], |
|
59 |
# ['modification_date', 'creation_date', 'owned_by', |
|
60 |
# 'eid', 'ecrit_par', 'inline1', 'date', 'type', |
|
61 |
# 'whatever', 'para', 'in_basket']) |
|
62 |
# NB: commit instead of rollback make following test fail with py2.5 |
|
63 |
# this sounds like a pysqlite/2.5 bug (the same eid is affected to |
|
64 |
# two different entities) |
|
65 |
self.mh.rollback() |
|
66 |
||
67 |
def test_add_attribute_varchar(self): |
|
68 |
self.failIf('shortpara' in self.schema) |
|
69 |
self.mh.cmd_add_attribute('Note', 'shortpara') |
|
70 |
self.failUnless('shortpara' in self.schema) |
|
71 |
self.assertEquals(self.schema['shortpara'].subjects(), ('Note', )) |
|
72 |
self.assertEquals(self.schema['shortpara'].objects(), ('String', )) |
|
73 |
# 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
|
74 |
notesql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' and name='%sNote'" % SQL_PREFIX)[0][0] |
0 | 75 |
fields = dict(x.strip().split()[:2] for x in notesql.split('(', 1)[1].rsplit(')', 1)[0].split(',')) |
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
|
76 |
self.assertEquals(fields['%sshortpara' % SQL_PREFIX], 'varchar(64)') |
0 | 77 |
self.mh.rollback() |
1787 | 78 |
|
0 | 79 |
def test_add_datetime_with_default_value_attribute(self): |
80 |
self.failIf('mydate' in self.schema) |
|
2642 | 81 |
self.failIf('shortpara' in self.schema) |
0 | 82 |
self.mh.cmd_add_attribute('Note', 'mydate') |
83 |
self.failUnless('mydate' in self.schema) |
|
84 |
self.assertEquals(self.schema['mydate'].subjects(), ('Note', )) |
|
85 |
self.assertEquals(self.schema['mydate'].objects(), ('Date', )) |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
86 |
testdate = date(2005, 12, 13) |
0 | 87 |
eid1 = self.mh.rqlexec('INSERT Note N')[0][0] |
88 |
eid2 = self.mh.rqlexec('INSERT Note N: N mydate %(mydate)s', {'mydate' : testdate})[0][0] |
|
89 |
d1 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid1}, 'x')[0][0] |
|
90 |
d2 = self.mh.rqlexec('Any D WHERE X eid %(x)s, X mydate D', {'x': eid2}, 'x')[0][0] |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
972
diff
changeset
|
91 |
self.assertEquals(d1, date.today()) |
0 | 92 |
self.assertEquals(d2, testdate) |
93 |
self.mh.rollback() |
|
1787 | 94 |
|
0 | 95 |
def test_rename_attribute(self): |
96 |
self.failIf('civility' in self.schema) |
|
97 |
eid1 = self.mh.rqlexec('INSERT Personne X: X nom "lui", X sexe "M"')[0][0] |
|
98 |
eid2 = self.mh.rqlexec('INSERT Personne X: X nom "l\'autre", X sexe NULL')[0][0] |
|
99 |
self.mh.cmd_rename_attribute('Personne', 'sexe', 'civility') |
|
100 |
self.failIf('sexe' in self.schema) |
|
101 |
self.failUnless('civility' in self.schema) |
|
102 |
# test data has been backported |
|
103 |
c1 = self.mh.rqlexec('Any C WHERE X eid %s, X civility C' % eid1)[0][0] |
|
104 |
self.failUnlessEqual(c1, 'M') |
|
105 |
c2 = self.mh.rqlexec('Any C WHERE X eid %s, X civility C' % eid2)[0][0] |
|
106 |
self.failUnlessEqual(c2, None) |
|
107 |
||
108 |
||
109 |
def test_workflow_actions(self): |
|
110 |
foo = self.mh.cmd_add_state(u'foo', ('Personne', 'Email'), initial=True) |
|
111 |
for etype in ('Personne', 'Email'): |
|
112 |
s1 = self.mh.rqlexec('Any N WHERE S state_of ET, ET name "%s", S name N' % |
|
113 |
etype)[0][0] |
|
114 |
self.assertEquals(s1, "foo") |
|
115 |
s1 = self.mh.rqlexec('Any N WHERE ET initial_state S, ET name "%s", S name N' % |
|
116 |
etype)[0][0] |
|
117 |
self.assertEquals(s1, "foo") |
|
118 |
bar = self.mh.cmd_add_state(u'bar', ('Personne', 'Email'), initial=True) |
|
119 |
baz = self.mh.cmd_add_transition(u'baz', ('Personne', 'Email'), |
|
120 |
(foo,), bar, ('managers',)) |
|
121 |
for etype in ('Personne', 'Email'): |
|
122 |
t1 = self.mh.rqlexec('Any N WHERE T transition_of ET, ET name "%s", T name N' % |
|
123 |
etype)[0][0] |
|
124 |
self.assertEquals(t1, "baz") |
|
125 |
gn = self.mh.rqlexec('Any GN WHERE T require_group G, G name GN, T eid %s' % baz)[0][0] |
|
126 |
self.assertEquals(gn, 'managers') |
|
1787 | 127 |
|
0 | 128 |
def test_add_entity_type(self): |
129 |
self.failIf('Folder2' in self.schema) |
|
130 |
self.failIf('filed_under2' in self.schema) |
|
131 |
self.mh.cmd_add_entity_type('Folder2') |
|
132 |
self.failUnless('Folder2' in self.schema) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
133 |
self.failUnless(self.execute('CWEType X WHERE X name "Folder2"')) |
0 | 134 |
self.failUnless('filed_under2' in self.schema) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
135 |
self.failUnless(self.execute('CWRType X WHERE X name "filed_under2"')) |
0 | 136 |
self.assertEquals(sorted(str(rs) for rs in self.schema['Folder2'].subject_relations()), |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
137 |
['created_by', 'creation_date', 'cwuri', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
138 |
'description', 'description_format', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
139 |
'eid', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
140 |
'filed_under2', 'has_text', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
141 |
'identity', 'in_basket', 'is', 'is_instance_of', |
0 | 142 |
'modification_date', 'name', 'owned_by']) |
143 |
self.assertEquals([str(rs) for rs in self.schema['Folder2'].object_relations()], |
|
144 |
['filed_under2', 'identity']) |
|
145 |
self.assertEquals(sorted(str(e) for e in self.schema['filed_under2'].subjects()), |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
146 |
sorted(str(e) for e in self.schema.entities() if not e.is_final())) |
0 | 147 |
self.assertEquals(self.schema['filed_under2'].objects(), ('Folder2',)) |
148 |
eschema = self.schema.eschema('Folder2') |
|
149 |
for cstr in eschema.constraints('name'): |
|
150 |
self.failUnless(hasattr(cstr, 'eid')) |
|
151 |
||
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
152 |
def test_add_drop_entity_type(self): |
0 | 153 |
self.mh.cmd_add_entity_type('Folder2') |
154 |
todoeid = self.mh.cmd_add_state(u'todo', 'Folder2', initial=True) |
|
155 |
doneeid = self.mh.cmd_add_state(u'done', 'Folder2') |
|
156 |
self.mh.cmd_add_transition(u'redoit', 'Folder2', (doneeid,), todoeid) |
|
157 |
self.mh.cmd_add_transition(u'markasdone', 'Folder2', (todoeid,), doneeid) |
|
158 |
self.commit() |
|
159 |
eschema = self.schema.eschema('Folder2') |
|
160 |
self.mh.cmd_drop_entity_type('Folder2') |
|
161 |
self.failIf('Folder2' in self.schema) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
162 |
self.failIf(self.execute('CWEType X WHERE X name "Folder2"')) |
0 | 163 |
# test automatic workflow deletion |
164 |
self.failIf(self.execute('State X WHERE NOT X state_of ET')) |
|
165 |
self.failIf(self.execute('Transition X WHERE NOT X transition_of ET')) |
|
166 |
||
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
167 |
def test_add_drop_relation_type(self): |
0 | 168 |
self.mh.cmd_add_entity_type('Folder2', auto=False) |
169 |
self.mh.cmd_add_relation_type('filed_under2') |
|
170 |
self.failUnless('filed_under2' in self.schema) |
|
171 |
self.assertEquals(sorted(str(e) for e in self.schema['filed_under2'].subjects()), |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
172 |
sorted(str(e) for e in self.schema.entities() if not e.is_final())) |
0 | 173 |
self.assertEquals(self.schema['filed_under2'].objects(), ('Folder2',)) |
174 |
self.mh.cmd_drop_relation_type('filed_under2') |
|
175 |
self.failIf('filed_under2' in self.schema) |
|
176 |
||
177 |
def test_add_relation_definition_nortype(self): |
|
178 |
self.mh.cmd_add_relation_definition('Personne', 'concerne2', 'Affaire') |
|
179 |
self.assertEquals(self.schema['concerne2'].subjects(), |
|
180 |
('Personne',)) |
|
181 |
self.assertEquals(self.schema['concerne2'].objects(), ('Affaire',)) |
|
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
182 |
self.mh.cmd_drop_relation_definition('Personne', 'concerne2', 'Affaire') |
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
183 |
self.failIf('concerne2' in self.schema) |
0 | 184 |
|
2251
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
185 |
def test_drop_relation_definition_existant_rtype(self): |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
186 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].subjects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
187 |
['Affaire', 'Personne']) |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
188 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].objects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
189 |
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision']) |
0 | 190 |
self.mh.cmd_drop_relation_definition('Personne', 'concerne', 'Affaire') |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
191 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].subjects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
192 |
['Affaire']) |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
193 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].objects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
194 |
['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
|
195 |
self.mh.cmd_add_relation_definition('Personne', 'concerne', 'Affaire') |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
196 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].subjects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
197 |
['Affaire', 'Personne']) |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
198 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].objects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
199 |
['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
|
200 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced types |
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
201 |
self.maxeid = self.execute('Any MAX(X)')[0][0] |
1787 | 202 |
|
0 | 203 |
def test_drop_relation_definition_with_specialization(self): |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
204 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].subjects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
205 |
['Affaire', 'Personne']) |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
206 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].objects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
207 |
['Affaire', 'Division', 'Note', 'Societe', 'SubDivision']) |
0 | 208 |
self.mh.cmd_drop_relation_definition('Affaire', 'concerne', 'Societe') |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
209 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].subjects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
210 |
['Affaire', 'Personne']) |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
211 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].objects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
212 |
['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
|
213 |
self.mh.cmd_add_relation_definition('Affaire', 'concerne', 'Societe') |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
214 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].subjects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
215 |
['Affaire', 'Personne']) |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
216 |
self.assertEquals(sorted(str(e) for e in self.schema['concerne'].objects()), |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
217 |
['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
|
218 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced types |
799ff50ddfe8
fix tests to avoid schema copy, pytest unittest_migration.py OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2124
diff
changeset
|
219 |
self.maxeid = self.execute('Any MAX(X)')[0][0] |
0 | 220 |
|
221 |
def test_rename_relation(self): |
|
222 |
self.skip('implement me') |
|
223 |
||
224 |
def test_change_relation_props_non_final(self): |
|
225 |
rschema = self.schema['concerne'] |
|
226 |
card = rschema.rproperty('Affaire', 'Societe', 'cardinality') |
|
227 |
self.assertEquals(card, '**') |
|
228 |
try: |
|
229 |
self.mh.cmd_change_relation_props('Affaire', 'concerne', 'Societe', |
|
230 |
cardinality='?*') |
|
231 |
card = rschema.rproperty('Affaire', 'Societe', 'cardinality') |
|
232 |
self.assertEquals(card, '?*') |
|
233 |
finally: |
|
234 |
self.mh.cmd_change_relation_props('Affaire', 'concerne', 'Societe', |
|
235 |
cardinality='**') |
|
1787 | 236 |
|
0 | 237 |
def test_change_relation_props_final(self): |
238 |
rschema = self.schema['adel'] |
|
239 |
card = rschema.rproperty('Personne', 'String', 'fulltextindexed') |
|
240 |
self.assertEquals(card, False) |
|
241 |
try: |
|
242 |
self.mh.cmd_change_relation_props('Personne', 'adel', 'String', |
|
243 |
fulltextindexed=True) |
|
244 |
card = rschema.rproperty('Personne', 'String', 'fulltextindexed') |
|
245 |
self.assertEquals(card, True) |
|
246 |
finally: |
|
247 |
self.mh.cmd_change_relation_props('Personne', 'adel', 'String', |
|
248 |
fulltextindexed=False) |
|
249 |
||
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
250 |
def test_sync_schema_props_perms(self): |
0 | 251 |
cursor = self.mh.rqlcursor |
252 |
nbrqlexpr_start = len(cursor.execute('RQLExpression X')) |
|
253 |
migrschema['titre']._rproperties[('Personne', 'String')]['order'] = 7 |
|
254 |
migrschema['adel']._rproperties[('Personne', 'String')]['order'] = 6 |
|
255 |
migrschema['ass']._rproperties[('Personne', 'String')]['order'] = 5 |
|
256 |
migrschema['Personne'].description = 'blabla bla' |
|
1787 | 257 |
migrschema['titre'].description = 'usually a title' |
0 | 258 |
migrschema['titre']._rproperties[('Personne', 'String')]['description'] = 'title for this person' |
1787 | 259 |
self.mh.cmd_sync_schema_props_perms(commit=False) |
260 |
||
0 | 261 |
self.assertEquals(cursor.execute('Any D WHERE X name "Personne", X description D')[0][0], |
262 |
'blabla bla') |
|
263 |
self.assertEquals(cursor.execute('Any D WHERE X name "titre", X description D')[0][0], |
|
264 |
'usually a title') |
|
265 |
self.assertEquals(cursor.execute('Any D WHERE X relation_type RT, RT name "titre",' |
|
266 |
'X from_entity FE, FE name "Personne",' |
|
267 |
'X description D')[0][0], |
|
268 |
'title for this person') |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
269 |
rinorder = [n for n, in cursor.execute( |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
270 |
'Any N ORDERBY O WHERE X is CWAttribute, X relation_type RT, RT name N,' |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
271 |
'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
|
272 |
'X ordernum O')] |
0 | 273 |
expected = [u'nom', u'prenom', u'promo', u'ass', u'adel', u'titre', |
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
274 |
u'web', u'tel', u'fax', u'datenaiss', u'test', 'description', u'firstname', |
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
275 |
u'creation_date', 'cwuri', u'modification_date'] |
0 | 276 |
self.assertEquals(rinorder, expected) |
277 |
||
278 |
# test permissions synchronization #################################### |
|
279 |
# new rql expr to add note entity |
|
280 |
eexpr = self._erqlexpr_entity('add', 'Note') |
|
281 |
self.assertEquals(eexpr.expression, |
|
282 |
'X ecrit_part PE, U in_group G, ' |
|
283 |
'PE require_permission P, P name "add_note", P require_group G') |
|
284 |
self.assertEquals([et.name for et in eexpr.reverse_add_permission], ['Note']) |
|
285 |
self.assertEquals(eexpr.reverse_read_permission, []) |
|
286 |
self.assertEquals(eexpr.reverse_delete_permission, []) |
|
287 |
self.assertEquals(eexpr.reverse_update_permission, []) |
|
288 |
# no more rqlexpr to delete and add para attribute |
|
289 |
self.failIf(self._rrqlexpr_rset('add', 'para')) |
|
290 |
self.failIf(self._rrqlexpr_rset('delete', 'para')) |
|
1787 | 291 |
# new rql expr to add ecrit_par relation |
0 | 292 |
rexpr = self._rrqlexpr_entity('add', 'ecrit_par') |
293 |
self.assertEquals(rexpr.expression, |
|
294 |
'O require_permission P, P name "add_note", ' |
|
295 |
'U in_group G, P require_group G') |
|
296 |
self.assertEquals([rt.name for rt in rexpr.reverse_add_permission], ['ecrit_par']) |
|
297 |
self.assertEquals(rexpr.reverse_read_permission, []) |
|
298 |
self.assertEquals(rexpr.reverse_delete_permission, []) |
|
299 |
# no more rqlexpr to delete and add travaille relation |
|
300 |
self.failIf(self._rrqlexpr_rset('add', 'travaille')) |
|
301 |
self.failIf(self._rrqlexpr_rset('delete', 'travaille')) |
|
302 |
# no more rqlexpr to delete and update Societe entity |
|
303 |
self.failIf(self._erqlexpr_rset('update', 'Societe')) |
|
304 |
self.failIf(self._erqlexpr_rset('delete', 'Societe')) |
|
305 |
# no more rqlexpr to read Affaire entity |
|
306 |
self.failIf(self._erqlexpr_rset('read', 'Affaire')) |
|
307 |
# rqlexpr to update Affaire entity has been updated |
|
308 |
eexpr = self._erqlexpr_entity('update', 'Affaire') |
|
309 |
self.assertEquals(eexpr.expression, 'X concerne S, S owned_by U') |
|
310 |
# no change for rqlexpr to add and delete Affaire entity |
|
311 |
self.assertEquals(len(self._erqlexpr_rset('delete', 'Affaire')), 1) |
|
312 |
self.assertEquals(len(self._erqlexpr_rset('add', 'Affaire')), 1) |
|
313 |
# no change for rqlexpr to add and delete concerne relation |
|
314 |
self.assertEquals(len(self._rrqlexpr_rset('delete', 'concerne')), 1) |
|
315 |
self.assertEquals(len(self._rrqlexpr_rset('add', 'concerne')), 1) |
|
316 |
# * migrschema involve: |
|
317 |
# * 8 deletion (2 in Affaire read + Societe + travaille + para rqlexprs) |
|
318 |
# * 1 update (Affaire update) |
|
319 |
# * 2 new (Note add, ecrit_par add) |
|
320 |
# remaining orphan rql expr which should be deleted at commit (composite relation) |
|
321 |
self.assertEquals(len(cursor.execute('RQLExpression X WHERE NOT ET1 read_permission X, NOT ET2 add_permission X, ' |
|
322 |
'NOT ET3 delete_permission X, NOT ET4 update_permission X')), 8+1) |
|
323 |
# finally |
|
1787 | 324 |
self.assertEquals(len(cursor.execute('RQLExpression X')), nbrqlexpr_start + 1 + 2) |
325 |
||
0 | 326 |
self.mh.rollback() |
327 |
||
328 |
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
|
329 |
rql = 'RQLExpression X WHERE ET is CWEType, ET %s_permission X, ET name %%(name)s' % action |
0 | 330 |
return self.mh.rqlcursor.execute(rql, {'name': ertype}) |
331 |
def _erqlexpr_entity(self, action, ertype): |
|
332 |
rset = self._erqlexpr_rset(action, ertype) |
|
333 |
self.assertEquals(len(rset), 1) |
|
334 |
return rset.get_entity(0, 0) |
|
335 |
def _rrqlexpr_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
|
336 |
rql = 'RQLExpression X WHERE ET is CWRType, ET %s_permission X, ET name %%(name)s' % action |
0 | 337 |
return self.mh.rqlcursor.execute(rql, {'name': ertype}) |
338 |
def _rrqlexpr_entity(self, action, ertype): |
|
339 |
rset = self._rrqlexpr_rset(action, ertype) |
|
340 |
self.assertEquals(len(rset), 1) |
|
341 |
return rset.get_entity(0, 0) |
|
1787 | 342 |
|
0 | 343 |
def test_set_size_constraint(self): |
344 |
# existing previous value |
|
345 |
try: |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
346 |
self.mh.cmd_set_size_constraint('CWEType', 'name', 128) |
0 | 347 |
finally: |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
348 |
self.mh.cmd_set_size_constraint('CWEType', 'name', 64) |
0 | 349 |
# non existing previous value |
350 |
try: |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
351 |
self.mh.cmd_set_size_constraint('CWEType', 'description', 256) |
0 | 352 |
finally: |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
353 |
self.mh.cmd_set_size_constraint('CWEType', 'description', None) |
0 | 354 |
|
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
|
355 |
def test_add_remove_cube_and_deps(self): |
0 | 356 |
cubes = set(self.config.cubes()) |
357 |
schema = self.repo.schema |
|
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2591
diff
changeset
|
358 |
self.assertEquals(sorted((str(s), str(o)) for s, o in schema['see_also']._rproperties.keys()), |
439 | 359 |
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'), |
360 |
('Bookmark', 'Bookmark'), ('Bookmark', 'Note'), |
|
361 |
('Note', 'Note'), ('Note', 'Bookmark')])) |
|
0 | 362 |
try: |
439 | 363 |
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
|
364 |
self.mh.cmd_remove_cube('email', removedeps=True) |
439 | 365 |
# file was there because it's an email dependancy, should have been removed |
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
|
366 |
self.failIf('email' in 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
|
367 |
self.failIf('file' in self.config.cubes()) |
1787 | 368 |
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File', 'Image', |
439 | 369 |
'sender', 'in_thread', 'reply_to', 'data_format'): |
370 |
self.failIf(ertype in schema, ertype) |
|
371 |
self.assertEquals(sorted(schema['see_also']._rproperties.keys()), |
|
372 |
sorted([('Folder', 'Folder'), |
|
373 |
('Bookmark', 'Bookmark'), |
|
374 |
('Bookmark', 'Note'), |
|
375 |
('Note', 'Note'), |
|
376 |
('Note', 'Bookmark')])) |
|
377 |
self.assertEquals(sorted(schema['see_also'].subjects()), ['Bookmark', 'Folder', 'Note']) |
|
378 |
self.assertEquals(sorted(schema['see_also'].objects()), ['Bookmark', 'Folder', 'Note']) |
|
379 |
self.assertEquals(self.execute('Any X WHERE X pkey "system.version.email"').rowcount, 0) |
|
380 |
self.assertEquals(self.execute('Any X WHERE X pkey "system.version.file"').rowcount, 0) |
|
381 |
except : |
|
382 |
import traceback |
|
383 |
traceback.print_exc() |
|
384 |
raise |
|
0 | 385 |
finally: |
47
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
386 |
self.mh.cmd_add_cube('email') |
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
|
387 |
self.failUnless('email' in 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
|
388 |
self.failUnless('file' in self.config.cubes()) |
1787 | 389 |
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File', 'Image', |
0 | 390 |
'sender', 'in_thread', 'reply_to', 'data_format'): |
391 |
self.failUnless(ertype in schema, ertype) |
|
392 |
self.assertEquals(sorted(schema['see_also']._rproperties.keys()), |
|
439 | 393 |
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'), |
394 |
('Bookmark', 'Bookmark'), |
|
395 |
('Bookmark', 'Note'), |
|
396 |
('Note', 'Note'), |
|
397 |
('Note', 'Bookmark')])) |
|
398 |
self.assertEquals(sorted(schema['see_also'].subjects()), ['Bookmark', 'EmailThread', 'Folder', 'Note']) |
|
399 |
self.assertEquals(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
|
400 |
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
|
401 |
from cubes.file.__pkginfo__ import version as file_version |
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
402 |
self.assertEquals(self.execute('Any V WHERE X value V, X pkey "system.version.email"')[0][0], |
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
403 |
email_version) |
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
404 |
self.assertEquals(self.execute('Any V WHERE X value V, X pkey "system.version.file"')[0][0], |
54087a269bdd
fix tests (some where broken after ECache was added)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
0
diff
changeset
|
405 |
file_version) |
0 | 406 |
# trick: overwrite self.maxeid to avoid deletion of just reintroduced |
407 |
# types (and their associated tables!) |
|
408 |
self.maxeid = self.execute('Any MAX(X)')[0][0] |
|
409 |
# why this commit is necessary is unclear to me (though without it |
|
410 |
# next test may fail complaining of missing tables |
|
1787 | 411 |
self.commit() |
972 | 412 |
|
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
|
413 |
|
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
|
414 |
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
|
415 |
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
|
416 |
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
|
417 |
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
|
418 |
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
|
419 |
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
|
420 |
cubes.remove('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
|
421 |
self.failIf('email' in 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
|
422 |
self.failUnless('file' in 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
|
423 |
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
|
424 |
'sender', 'in_thread', 'reply_to'): |
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
|
425 |
self.failIf(ertype in schema, ertype) |
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
|
426 |
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
|
427 |
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
|
428 |
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
|
429 |
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
|
430 |
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
|
431 |
self.mh.cmd_add_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
|
432 |
self.failUnless('email' in 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
|
433 |
# 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
|
434 |
# types (and their associated tables!) |
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
|
435 |
self.maxeid = self.execute('Any MAX(X)')[0][0] |
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
|
436 |
# 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
|
437 |
# next test may fail complaining of missing tables |
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
|
438 |
self.commit() |
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
|
439 |
|
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
|
440 |
def test_remove_dep_cube(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
|
441 |
ex = self.assertRaises(ConfigurationError, self.mh.cmd_remove_cube, 'file') |
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
|
442 |
self.assertEquals(str(ex), "can't remove cube file, used as a dependency") |
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
|
443 |
|
972 | 444 |
def test_set_state(self): |
445 |
user = self.session.user |
|
446 |
self.mh.set_state(user.eid, 'deactivated') |
|
447 |
user.clear_related_cache('in_state', 'subject') |
|
1787 | 448 |
self.assertEquals(user.state, 'deactivated') |
449 |
||
0 | 450 |
if __name__ == '__main__': |
451 |
unittest_main() |