def test_superuser_collection_ownership_filtering(client: R2RClient, superuser_login, config):
    """Test the ownerOnly filter for superusers."""
    # Create a regular user
    user_email = f"regular_{uuid.uuid4()}@test.com"
    user_password = "password123"
    client.users.create(user_email, user_password)

    # Create a collection as superuser
    superuser_collection = client.collections.create(name="Superuser Collection").results
    superuser_id = client.users.me().results.id

    # List all collections as superuser (without filter)
    all_collections_count = len(client.collections.list().results)
    assert all_collections_count > 0, "Superuser should see collections"

    # List only owned collections as superuser
    owned_collections = client.collections.list(owner_only=True).results
    owned_count = len(owned_collections)
    assert owned_count > 0, "Superuser should see owned collections"
    assert owned_count < all_collections_count, "Filtered list should be smaller than all collections"

    # Verify the superuser collection is in the owned list
    assert any(str(col.id) == str(superuser_collection.id) for col in owned_collections), \
        "Superuser collection should be in the owned list"

    # Cleanup
    client.collections.delete(superuser_collection.id)
    client.users.logout()
Test the ownerOnly filter for superusers.
py/tests/integration/test_users.py