common/test/unittest_mixins.py
author sylvain.thenault@logilab.fr
Thu, 30 Apr 2009 08:51:54 +0200
branchtls-sprint
changeset 1564 de0548cb0ab8
parent 1398 5fe84a5f7035
child 1802 d628defebc17
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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')
970
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')
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')
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()