def test_get_role(self): """Tests the user getRole function.""" user = User() self.assertEquals(user.getRole(), 'user') user.role = USER.PUBLISHER self.assertEquals(user.getRole(), 'publisher') user.role = USER.ADMIN self.assertEquals(user.getRole(), 'admin')
def test_role_predicates(self): """Test predicate functions that identify user roles.""" user = User() self.assertFalse(user.isAdmin()) self.assertFalse(user.isPublisher()) user.role = USER.PUBLISHER self.assertTrue(user.isPublisher()) self.assertFalse(user.isAdmin()) user.role = USER.ADMIN self.assertTrue(user.isPublisher()) self.assertTrue(user.isAdmin())