def METHOD_NAME(
    auth_client, public_channel, other_user, role, expected_code
):
    response = auth_client.post(
        f"/api/channels/{public_channel.name}/members",
        json={"username": other_user.username, "role": role},
    )
    assert response.status_code == expected_code
    if expected_code == 201:
        response = auth_client.get(f"/api/channels/{public_channel.name}/members")
        response.raise_for_status()
        for element in response.json():
            if element["user"]["username"] == other_user.username:
                assert element["role"] == role
                break
        else:
            raise RuntimeError(f"User '{other_user.username}' not found.")