hooks/test/unittest_integrity.py
author Julien Cristau <julien.cristau@logilab.fr>
Thu, 10 Oct 2013 10:02:29 +0200
branchstable
changeset 9306 8ab0e601d418
parent 9275 ea7fd598ced9
child 9548 be001628edad
permissions -rw-r--r--
[web] don't rename resources in gen-static-datadir We should use the result from WebConfiguration.locate_resource to know which file to copy, not what name to copy it to. The destination file should be the name of the resource, as the client will request it. This matters in the case of cubicweb.css which locate_resource might rewrite to cubicweb.old.css. Closes #3206129
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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_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
    45
        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
    46
                          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
    47
                          '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
    48
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
    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
    50
        # 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
    51
        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
    52
        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
    53
                          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
    54
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
    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
    56
        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
    57
        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
    58
        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
    59
                     '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
    60
        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
    61
        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
    62
        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
    63
        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
    64
        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
    65
        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
    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), 0)
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    68
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    69
    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
    70
        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
    71
        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
    72
        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
    73
                     '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
    74
        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
    75
        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
    76
        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
    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
        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
    79
        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
    80
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    81
    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
    82
        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
    83
        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
    84
        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
    85
                     '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
    86
        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
    87
                     '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
    88
        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
    89
        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
    90
        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
    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
        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
    93
        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
    94
        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
    95
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    96
    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
    97
        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
    98
        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
    99
            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
   100
        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
   101
                          {'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
   102
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   103
    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
   104
        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
   105
        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
   106
        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
   107
        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
   108
        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
   109
        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
   110
        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
   111
4813efcee2c6 [test] test extracted from unittest_hooks + new test for unique constraint check
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   112
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
   113
    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
   114
    unittest_main()