def test_multiple_api_keys(client: R2RClient):
    """Test creating and managing multiple API keys for a single user."""
    email = f"{uuid.uuid4()}@example.com"
    password = "multi_key_test_password"
    user_id = client.users.create(email, password).results.id
    client.users.login(email, password)

    # Create multiple API keys
    key_ids = []
    for i in range(3):
        key_resp = client.users.create_api_key(user_id).results
        key_ids.append(key_resp.key_id)

    # List and verify all keys exist
    list_resp = client.users.list_api_keys(user_id).results
    assert len(list_resp) >= 3, "Not all API keys were created"

    # Delete keys one by one and verify counts
    for key_id in key_ids:
        client.users.delete_api_key(user_id, key_id)
        current_keys = client.users.list_api_keys(user_id).results
        assert not any(k.key_id == key_id for k in current_keys), (
            f"Key {key_id} still exists after deletion")

    client.users.logout()
Test creating and managing multiple API keys for a single user.
py/tests/integration/test_users.py