import pytest
from parsec.models.adapters.openai_adapter import OpenAIAdapter
from parsec.validators.json_validator import JSONValidator
from parsec.enforcement.engine import EnforcementEngine

@pytest.mark.asyncio
async def test_basic_enforcement():
    adapter = OpenAIAdapter(api_key="test-key", model="gpt-4o-mini")
    validator = JSONValidator()
    engine = EnforcementEngine(adapter, validator)

    schema = {
        "type": "object",
        "properties": {"name": {"type": "string"}}
    }

    # This will fail without real API key, but tests structure
    try:
        result = await engine.enforce("Get name: John", schema)
        assert result is not None
    except:
        pass  # Expected without real key
    finally:
        # Cleanup: close the async client to prevent resource warnings
        if adapter._client is not None:
            await adapter._client.close()
