author | Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr> |
Tue, 14 May 2013 15:26:24 +0200 | |
changeset 8970 | 0a1bd0c590e2 |
parent 8694 | d901c36bcfce |
child 9275 | ea7fd598ced9 |
permissions | -rw-r--r-- |
6964
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
# |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
# This file is part of CubicWeb. |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
# |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
# any later version. |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
# |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
15 |
# details. |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
# |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
"""functional tests for integrity hooks""" |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
20 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
from cubicweb import ValidationError |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
from cubicweb.devtools.testlib import CubicWebTC |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
class CoreHooksTC(CubicWebTC): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
def test_delete_internal_entities(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
27 |
self.assertRaises(ValidationError, self.execute, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
'DELETE CWEType X WHERE X name "CWEType"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
self.assertRaises(ValidationError, self.execute, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
'DELETE CWRType X WHERE X name "relation_type"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
self.assertRaises(ValidationError, self.execute, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
'DELETE CWGroup X WHERE X name "owners"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
def test_delete_required_relations_subject(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
self.execute('INSERT CWUser X: X login "toto", X upassword "hop", X in_group Y ' |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
'WHERE Y name "users"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
self.execute('DELETE X in_group Y WHERE X login "toto", Y name "users"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
self.assertRaises(ValidationError, self.commit) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
self.execute('DELETE X in_group Y WHERE X login "toto"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
self.execute('SET X in_group Y WHERE X login "toto", Y name "guests"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
def test_delete_required_relations_object(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
self.skipTest('no sample in the schema ! YAGNI ? Kermaat ?') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
46 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
def test_static_vocabulary_check(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
self.assertRaises(ValidationError, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
self.execute, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
'SET X composite "whatever" WHERE X from_entity FE, FE name "CWUser", X relation_type RT, RT name "in_group"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
def test_missing_required_relations_subject_inline(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
53 |
# missing in_group relation |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
54 |
self.execute('INSERT CWUser X: X login "toto", X upassword "hop"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
55 |
self.assertRaises(ValidationError, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
56 |
self.commit) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
57 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
58 |
def test_composite_1(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
59 |
self.execute('INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
60 |
self.execute('INSERT EmailPart X: X content_format "text/plain", X ordernum 1, X content "this is a test"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
61 |
self.execute('INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y, X parts P ' |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
62 |
'WHERE Y is EmailAddress, P is EmailPart') |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6964
diff
changeset
|
63 |
self.assertTrue(self.execute('Email X WHERE X sender Y')) |
6964
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
64 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
65 |
self.execute('DELETE Email X') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
66 |
rset = self.execute('Any X WHERE X is EmailPart') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
67 |
self.assertEqual(len(rset), 1) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
68 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
69 |
rset = self.execute('Any X WHERE X is EmailPart') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
70 |
self.assertEqual(len(rset), 0) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
71 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
72 |
def test_composite_2(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
73 |
self.execute('INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
74 |
self.execute('INSERT EmailPart X: X content_format "text/plain", X ordernum 1, X content "this is a test"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
75 |
self.execute('INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y, X parts P ' |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
76 |
'WHERE Y is EmailAddress, P is EmailPart') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
77 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
78 |
self.execute('DELETE Email X') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
79 |
self.execute('DELETE EmailPart X') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
80 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
81 |
rset = self.execute('Any X WHERE X is EmailPart') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
82 |
self.assertEqual(len(rset), 0) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
83 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
84 |
def test_composite_redirection(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
85 |
self.execute('INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
86 |
self.execute('INSERT EmailPart X: X content_format "text/plain", X ordernum 1, X content "this is a test"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
87 |
self.execute('INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y, X parts P ' |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
88 |
'WHERE Y is EmailAddress, P is EmailPart') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
89 |
self.execute('INSERT Email X: X messageid "<2345>", X subject "test2", X sender Y, X recipients Y ' |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
90 |
'WHERE Y is EmailAddress') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
91 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
92 |
self.execute('DELETE X parts Y WHERE X messageid "<1234>"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
93 |
self.execute('SET X parts Y WHERE X messageid "<2345>"') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
94 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
95 |
rset = self.execute('Any X WHERE X is EmailPart') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
96 |
self.assertEqual(len(rset), 1) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
97 |
self.assertEqual(rset.get_entity(0, 0).reverse_parts[0].messageid, '<2345>') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
98 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
99 |
def test_unsatisfied_constraints(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
100 |
releid = self.execute('SET U in_group G WHERE G name "owners", U login "admin"')[0][0] |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
101 |
with self.assertRaises(ValidationError) as cm: |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
102 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
103 |
self.assertEqual(cm.exception.errors, |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
104 |
{'in_group-object': u'RQLConstraint NOT O name "owners" failed'}) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
105 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
106 |
def test_unique_constraint(self): |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
107 |
req = self.request() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
108 |
entity = req.create_entity('CWGroup', name=u'trout') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
109 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
110 |
self.assertRaises(ValidationError, req.create_entity, 'CWGroup', name=u'trout') |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
111 |
self.rollback() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
112 |
req.execute('SET X name "trout" WHERE X eid %(x)s', {'x': entity.eid}) |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
113 |
self.commit() |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
114 |
|
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
115 |
if __name__ == '__main__': |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
116 |
from logilab.common.testlib import unittest_main |
4813efcee2c6
[test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
117 |
unittest_main() |