web/test/unittest_views_actions.py
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Fri, 25 Sep 2009 20:49:41 +0200
branchstable
changeset 3486 ea6bf6f9ba0c
parent 2650 18aec79ec3a3
child 2773 b2530e3e0afb
child 4212 ab6573088b4a
permissions -rw-r--r--
[cwctl] improve dialog messages

"""

:organization: Logilab
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
from logilab.common.testlib import unittest_main

from cubicweb.devtools.apptest import EnvBasedTC

class ActionsTC(EnvBasedTC):
    def test_view_action(self):
        req = self.request(__message='bla bla bla', vid='rss', rql='CWUser X')
        rset = self.execute('CWUser X')
        vaction = [action for action in self.vreg['actions'].possible_vobjects(req, rset=rset)
                   if action.id == 'view'][0]
        self.assertEquals(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X')

    def test_sendmail_action(self):
        req = self.request()
        rset = self.execute('Any X WHERE X login "admin"', req=req)
        self.failUnless([action for action in self.vreg['actions'].possible_vobjects(req, rset=rset)
                         if action.id == 'sendemail'])
        self.login('anon')
        req = self.request()
        rset = self.execute('Any X WHERE X login "anon"', req=req)
        self.failIf([action for action in self.vreg['actions'].possible_vobjects(req, rset=rset)
                     if action.id == 'sendemail'])

if __name__ == '__main__':
    unittest_main()