author | sylvain.thenault@logilab.fr |
Thu, 09 Apr 2009 13:51:01 +0200 | |
branch | tls-sprint |
changeset 1316 | 6d71d38822ee |
parent 970 | b52b1679f4e4 |
child 1398 | 5fe84a5f7035 |
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') |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
10 |
self.assertEquals(es.state_of[0].name, 'EUser') |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
11 |
|
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') |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
17 |
self.assertEquals(et.transition_of[0].name, 'EUser') |
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') |
b52b1679f4e4
add test for some WorkfloableMixIn methods
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
23 |
|
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() |