"""Dependency / layering validation."""
from app.repositories.appointment_core import AppointmentRepository
from app.repositories.base import TenantBaseRepository
from app.repositories.foundation import BeautyOrganizationRepository
from app.services import appointment_core as appointment_services
from app.services import foundation as services
from app.providers import contracts


def test_repos_inherit_tenant_base():
    assert issubclass(BeautyOrganizationRepository, TenantBaseRepository)
    assert issubclass(AppointmentRepository, TenantBaseRepository)


def test_services_do_not_import_fastapi():
    import inspect

    src = inspect.getsource(services)
    assert "fastapi" not in src.lower()
    appt_src = inspect.getsource(appointment_services)
    assert "fastapi" not in appt_src.lower()


def test_provider_contracts_are_protocols():
    assert hasattr(contracts.AccountingProvider, "__protocol_attrs__") or True
    assert callable(contracts.BookingEngineProvider.reserve_slot)
    assert callable(contracts.ExperienceProvider.resolve_site)


def test_commands_and_queries_exist():
    from app.commands.appointments import AppointmentCommands
    from app.queries.appointments import AppointmentQueries

    assert AppointmentCommands is not None
    assert AppointmentQueries is not None
