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)
def setUp(self): self.permission = Permission(name = "menu_general") self.permission.put()
def test_get_permission_by_name(self): self.assertEquals(self.permission.name, Permission.by_name('menu_general').name)
def __getattr__(self, permission): permission = Permission.by_name(permission) if permission and self.permissions: return is_in_list(permission.key(), self.permissions) return False
def has_permission(self, permission): return is_in_list(Permission.by_name(permission).key(), self.permissions)
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()