def test_check_permission(self): authenticator.login("frank", "thetank") authorizor.add_permission("paint") authorizor.permit_user("paint", "frank") self.assertTrue(authorizor.check_permission("paint", "frank")) with self.assertRaises(PermissionError): authorizor.check_permission("doesntexist", "frank")
def test_check_permission_not_permitted_user(self): authenticator.add_user('user_2', 'user2pwd') authenticator.login('user_2', 'user2pwd') with self.assertRaises(NotPermittedError): authorizor.check_permission('test', 'user_2')
def test_check_permission_invalid_permission(self): with self.assertRaises(PermissionError): authorizor.check_permission('inv_perm', 'user')
def test_check_permission_not_logged_in_user(self): with self.assertRaises(NotLoggedInError): authorizor.check_permission('test', 'inv_user')
def test_exception_not_permitted(self): authenticator.login("frank", "thetank") authorizor.add_permission("paint") with self.assertRaises(NotPermittedError): authorizor.check_permission("paint", "frank")
def test_exception_not_logged_in(self): authorizor.add_permission("paint") with self.assertRaises(NotLoggedInError): authorizor.check_permission("paint", "frank")