def test_get_role(self): write_test_data() session = connection.get_session() role_api = RoleApi(session) role = role_api.get_role(role_id="1") assert role.get("name") == "test_role1" try: role = role_api.get_role(role_id="10") except exception.RoleNotFound as e: assert isinstance(e, exception.RoleNotFound)
def test_update_role(self): write_test_data() session = connection.get_session() role_api = RoleApi(session) role = {"name": "test_role1_update"} role_api.update_role("1", role) role = role_api.get_role("1") assert role.get("name") == "test_role1_update" try: role = {"name": "test_role2"} role_api.update_role("1", role) except exception.Conflict as e: assert isinstance(e, exception.Conflict) else: raise Exception("Conflict didn't happen")
def test_create_role(self): write_domain_data() write_project_data() write_group_data() write_user_data() session = connection.get_session() role_api = RoleApi(session) roles = role_api.list_roles() assert len(roles) == 0 roles = get_role_data() for r in roles: role = r.to_dict() role_api.create_role(role) roles = role_api.list_roles() assert len(roles) == 3
def test_delete_role(self): write_test_data() session = connection.get_session() role_api = RoleApi(session) urms = role_api.list_user_role_membership(role_id="2") assert len(urms) == 2 grms = role_api.list_group_role_membership(role_id="2") assert len(grms) == 2 role_api.delete_role(role_id="2") try: group = role_api.get_role(role_id="2") except exception.RoleNotFound as e: assert isinstance(e, exception.RoleNotFound) else: raise Exception("RoleNotFound didn't happen") ugms = session.query(default_model.UserRoleMembership).filter_by(role_id="2").all() assert len(ugms) == 0 grms = session.query(default_model.GroupRoleMembership).filter_by(role_id="2").all() assert len(grms) == 0
def test_list_group_role_membership(self): write_test_data() session = connection.get_session() role_api = RoleApi(session) grms = role_api.list_group_role_membership(role_id="2") assert len(grms) == 2
def test_list_roles(self): write_test_data() session = connection.get_session() role_api = RoleApi(session) roles = role_api.list_roles() assert len(roles) == 3