web.tests.testuserdecorators

Package web :: Package tests :: Module testuserdecorators |
[hide private]
[frames] | no frames]

# Source Code for Module web.tests.testuserdecorators

     1  import unittest
     2  from user.userdecorators import has_permissions
     3  from  config import noreply_email
     4  from web.webapi import SeeOther
     5  import web
     6  from user.model import User, Role, Action
     7
     8 -class TestUserDecorators(unittest.TestCase):
     9 -    def setUp(self):
    10          self.anonymous_user = User('anonymous', '', noreply_email)
    11          self.test_role = Role('test_role', [self.anonymous_user])
    12          self.test_action = Action('test_action', [self.test_role])
    13          web.ctx.orm.add(self.anonymous_user)
    14          web.ctx.orm.add(self.test_role)
    15          web.ctx.orm.add(self.test_action)
    16
    17 -    def tearDown(self):
    18          web.ctx.orm.delete(self.anonymous_user)
    19          web.ctx.orm.delete(self.test_role)
    20          web.ctx.orm.delete(self.test_action)
    21
    22 -    def test_has_permissions(self):
    23          self.check_perms()
    24
    25          self.test_role.users = []
    26          web.ctx.orm.commit()
    27          try:
    28              self.check_perms()
    29              raise Exception
    30          except SeeOther:
    31              pass
    32
    33      @has_permissions('test_action')
    34 -    def check_perms(self):
    35          pass
    36
    37 -def suite():
    38     suite = unittest.TestSuite()
    39     suite.addTest(unittest.makeSuite(TestUserDecorators))
    40     return suite
    41