def test_api_create_role(): """ Test creating a role """ url = helper.api.role.create.url user = helper.api.user.current data = { "name": helper.api.role.name(), "owners": [user["next_id"]], "administrators": [user["next_id"]], "description": helper.api.role.description(), } assert assert_api_post_requires_auth(url=url, json=data) response = requests.post(url=url, headers={"Authorization": user["token"]}, json=data) result = assert_api_success(response) assert result["data"] assert result["data"]["name"] == data["name"] assert result["data"]["owners"] == data["owners"] assert result["data"]["administrators"] == data["administrators"] assert result["data"]["description"] == data["description"]
def test_api_propose_role_member(): """ Test a user proposing to add themselves to a role """ owner = helper.api.user.current role = helper.api.role.create.new(user=owner) user = helper.api.user.current2 url = helper.api.role.member.propose.url(role_id=role["id"]) data = {"id": user["next_id"]} assert assert_api_post_requires_auth(url=url, json=data) response = requests.post(url=url, headers={"Authorization": user["token"]}, json=data) result = assert_api_success(response) assert result["proposal_id"] time.sleep(0.5) # temporary until API refactored to return the proposal proposal = helper.api.proposal.get(result["proposal_id"], owner) assert proposal["id"] == result["proposal_id"] assert proposal["status"] == "OPEN" assert proposal["type"] == "ADD_ROLE_MEMBER" assert proposal["object"] == role["id"] assert proposal["target"] == user["next_id"] assert proposal["opener"] == user["next_id"]