author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 26 May 2009 09:31:44 +0200 | |
changeset 1938 | bf27b4190739 |
parent 1802 | d628defebc17 |
child 1977 | 606923dff11b |
permissions | -rw-r--r-- |
970
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
1 |
from logilab.common.testlib import unittest_main |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
2 |
from cubicweb.devtools.apptest import EnvBasedTC |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
3 |
|
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
4 |
class WorkfloableMixInTC(EnvBasedTC): |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
5 |
def test_wf_state(self): |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
6 |
s = self.add_entity('State', name=u'activated') |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
7 |
self.execute('SET X state_of ET WHERE ET name "Bookmark", X eid %(x)s', |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
8 |
{'x': s.eid}) |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
9 |
es = self.user().wf_state('activated') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
970
diff
changeset
|
10 |
self.assertEquals(es.state_of[0].name, 'CWUser') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
11 |
|
970
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
12 |
def test_wf_transition(self): |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
13 |
t = self.add_entity('Transition', name=u'deactivate') |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
14 |
self.execute('SET X transition_of ET WHERE ET name "Bookmark", X eid %(x)s', |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
15 |
{'x': t.eid}) |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
16 |
et = self.user().wf_transition('deactivate') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
970
diff
changeset
|
17 |
self.assertEquals(et.transition_of[0].name, 'CWUser') |
970
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
18 |
|
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
19 |
def test_change_state(self): |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
20 |
user = self.user() |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
21 |
user.change_state(user.wf_state('deactivated').eid) |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
22 |
self.assertEquals(user.state, 'deactivated') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
23 |
|
970
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
24 |
if __name__ == '__main__': |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
25 |
unittest_main() |