def test_non_owner_member_cannot_add_other_users(
    user_owned_collection,
    another_normal_user_client: R2RClient,
    normal_user_client: R2RClient,
):
    """A member who is not the owner should not be able to add other users."""
    # Another user tries to add a third user
    third_email = f"third_user_{uuid.uuid4()}@test.com"
    third_password = "third_password"
    # Need to create third user as a superuser or owner
    normal_user_email = normal_user_client.users.me().results.email
    normal_user_client.users.logout()

    # Login as normal user again
    # NOTE: We assume normal_password known here; in a real scenario, store it or use fixtures more dynamically
    # This code snippet assumes we have these credentials available.
    # If not, manage credentials store in fixture creation.
    normal_user_client.users.login(normal_user_email, "normal_password")
    third_user_id = normal_user_client.users.create(third_email,
                                                    third_password).results.id

    # Add another user as a member
    another_user_id = another_normal_user_client.users.me().results.id
    normal_user_client.collections.add_user(user_owned_collection,
                                            another_user_id)

    # Now, another_normal_user_client tries to add the third user
    with pytest.raises(R2RException) as exc_info:
        another_normal_user_client.collections.add_user(
            user_owned_collection, third_user_id)
    assert exc_info.value.status_code == 403, (
        "Non-owner member should not be able to add users.")
A member who is not the owner should not be able to add other users.
py/tests/integration/test_collections_users_interaction.py