import pytest
from httpx import AsyncClient
from app import app

@pytest.mark.asyncio
async def test_universal_match_dedupe():
    async with AsyncClient(app=app, base_url="http://test") as client:
        response = await client.post(
            "/api/v1/match",
            json={
                "mode": "dedupe",
                "source": {
                    "data": [
                        {"id": "1", "name": "John Smith", "email": "john@example.com"},
                        {"id": "2", "name": "John Smyth", "email": "john@example.com"}
                    ],
                    "format": "json"
                },
                "threshold": 80
            },
            headers={"Authorization": "Bearer test-token"}
        )
        assert response.status_code == 200
        result = response.json()
        assert result["status"] in ["completed", "processing"]
        assert "auto_detected_config" in result