Пример #1
0
class PermissionTestCase(unittest.TestCase):

    def setUp(self):
        self.permission = Permission(name = "menu_general")
        self.permission.put()
     
    def test_calling_an_existing_method(self):
        self.assertFalse(self.permission.hello)
           
    def test_when_permission_is_defined(self):
        self.assertTrue(self.permission.menu_general)
        
    def test_get_permission_by_name(self):
        self.assertEquals(self.permission.name, Permission.by_name('menu_general').name)
Пример #2
0
 def setUp(self):
     self.permission = Permission(name = "menu_general")
     self.permission.put()
Пример #3
0
 def test_get_permission_by_name(self):
     self.assertEquals(self.permission.name, Permission.by_name('menu_general').name)
Пример #4
0
 def __getattr__(self, permission):
     permission = Permission.by_name(permission)
     if permission and self.permissions:
         return is_in_list(permission.key(), self.permissions)
     return False        
Пример #5
0
 def has_permission(self, permission):
     return is_in_list(Permission.by_name(permission).key(), self.permissions)
Пример #6
0
 def add_permissions(self, permission_names):
     for i in range(len(permission_names)):
         self.permissions.append(Permission.build_permission(permission_names[i]).key())
     self.put()