author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 23 Sep 2009 15:29:31 +0200 | |
branch | stable |
changeset 3437 | a30b5b5138a4 |
parent 2920 | 64322aa83a1d |
child 2968 | 0e3460341023 |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
2 |
"""unit/functional tests for cubicweb.server.hookhelper |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
3 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
4 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1787
diff
changeset
|
8 |
""" |
0 | 9 |
|
10 |
from logilab.common.testlib import unittest_main |
|
11 |
from cubicweb.devtools.apptest import RepositoryBasedTC |
|
12 |
||
1787 | 13 |
from cubicweb.server.pool import LateOperation, Operation, SingleLastOperation |
0 | 14 |
from cubicweb.server.hookhelper import * |
15 |
||
16 |
||
17 |
class HookHelpersTC(RepositoryBasedTC): |
|
1787 | 18 |
|
0 | 19 |
def setUp(self): |
20 |
RepositoryBasedTC.setUp(self) |
|
21 |
self.hm = self.repo.hm |
|
1787 | 22 |
|
0 | 23 |
def test_late_operation(self): |
24 |
session = self.session |
|
25 |
l1 = LateOperation(session) |
|
26 |
l2 = LateOperation(session) |
|
27 |
l3 = Operation(session) |
|
28 |
self.assertEquals(session.pending_operations, [l3, l1, l2]) |
|
1787 | 29 |
|
0 | 30 |
def test_single_last_operation(self): |
31 |
session = self.session |
|
32 |
l0 = SingleLastOperation(session) |
|
33 |
l1 = LateOperation(session) |
|
34 |
l2 = LateOperation(session) |
|
35 |
l3 = Operation(session) |
|
36 |
self.assertEquals(session.pending_operations, [l3, l1, l2, l0]) |
|
37 |
l4 = SingleLastOperation(session) |
|
38 |
self.assertEquals(session.pending_operations, [l3, l1, l2, l4]) |
|
1787 | 39 |
|
0 | 40 |
def test_global_operation_order(self): |
41 |
from cubicweb.server import hooks, schemahooks |
|
42 |
session = self.session |
|
43 |
op1 = hooks.DelayedDeleteOp(session) |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2455
diff
changeset
|
44 |
op2 = schemahooks.MemSchemaRDefDel(session) |
0 | 45 |
# equivalent operation generated by op2 but replace it here by op3 so we |
46 |
# can check the result... |
|
2637
07103211e511
R [test] update and fix deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2455
diff
changeset
|
47 |
op3 = schemahooks.MemSchemaNotifyChanges(session) |
0 | 48 |
op4 = hooks.DelayedDeleteOp(session) |
49 |
op5 = hooks.CheckORelationOp(session) |
|
50 |
self.assertEquals(session.pending_operations, [op1, op2, op4, op5, op3]) |
|
1787 | 51 |
|
0 | 52 |
if __name__ == '__main__': |
53 |
unittest_main() |