def test_some_users(self): """ Retrieve all users for a role """ # Setup the response for MockServer BonitaServer.use('localhost', 9090, 'restuser', 'restbpm') url = '/identityAPI/getAllUsersInRoleAndGroup' code = 200 user1_xml = build_bonita_user_xml(uuid='1234', password='', username='******') user2_xml = build_bonita_user_xml(uuid='6789', password='', username='******') xml = build_xml_list([user1_xml, user2_xml]) BonitaServer.set_response_list([[url, code, xml]]) role = BonitaRole('myrole', '', '') role.uuid = '1234' group = BonitaGroup('mygroup', '', '') group.uuid = '2345' users = BonitaUser.find_by_role_and_group(role, group) assert isinstance(users, list) assert len(users) == 2 for user in users: assert isinstance(user, BonitaUser) sorted_users = sorted(users, key=lambda user: user.uuid) assert sorted_users[0].uuid == u'1234' assert sorted_users[1].uuid == u'6789'
def test_no_user(self): """ Retrieve all users for a group but there are none """ # Setup the response for MockServer BonitaServer.use('localhost', 9090, 'restuser', 'restbpm') url = '/identityAPI/getAllUsersInGroup' code = 200 xml = build_xml_list([]) BonitaServer.set_response_list([[url, code, xml]]) group = BonitaGroup('mygroup', '', '') group.uuid = '2345' users = BonitaUser.find_by_group(group) assert isinstance(users, list) assert len(users) == 0
def test_no_user(self): """ Retrieve all users for a role but there are none """ # Setup the response for MockServer BonitaServer.use('localhost', 9090, 'restuser', 'restbpm') url = '/identityAPI/getAllUsersInRole' code = 200 xml = build_xml_list([]) BonitaServer.set_response_list([[url, code, xml]]) role = BonitaRole('myrole', '', '') role.uuid = '1234' users = BonitaUser.find_by_role(role) assert isinstance(users, list) assert len(users) == 0