"""Dependency / layering validation."""
from app.repositories.base import TenantBaseRepository
from app.repositories.foundation import ClinicRepository
from app.repositories.profiles import DoctorRepository
from app.services import foundation as services
from app.services import profiles as profile_services
from app.providers import contracts


def test_repos_inherit_tenant_base():
    assert issubclass(ClinicRepository, TenantBaseRepository)
    assert issubclass(DoctorRepository, TenantBaseRepository)


def test_services_do_not_import_fastapi():
    import inspect

    src = inspect.getsource(services)
    assert "fastapi" not in src.lower()
    profile_src = inspect.getsource(profile_services)
    assert "fastapi" not in profile_src.lower()


def test_provider_contracts_are_protocols():
    assert hasattr(contracts.AccountingProvider, "__protocol_attrs__") or True
    assert callable(contracts.DeliveryProvider.request_delivery)


def test_commands_and_queries_exist():
    from app.commands.profiles import ProfileCommands
    from app.queries.profiles import ProfileQueries

    assert ProfileCommands is not None
    assert ProfileQueries is not None
