"""Pytest fixtures shared across the entire backend test suite.

These fixtures are available in every test without explicit import.
More specific fixtures (tenant_acme, alice, acme_tree …) live in
``tests/conftest.py`` alongside the tests that need them.
"""

from __future__ import annotations

import pytest


# ---------------------------------------------------------------------------
# HTTP client
# ---------------------------------------------------------------------------

@pytest.fixture
def api_client():
    """Unauthenticated DRF APIClient.

    Call ``api_client.force_login(user)`` or
    ``api_client.force_authenticate(user=user)`` inside your test when you
    need an authenticated session.
    """
    from rest_framework.test import APIClient

    return APIClient()


@pytest.fixture
def auth_client(user):
    """APIClient already authenticated as the default ``user`` fixture."""
    from rest_framework.test import APIClient

    client = APIClient()
    client.force_authenticate(user=user)
    return client


# ---------------------------------------------------------------------------
# Core domain objects
# ---------------------------------------------------------------------------

@pytest.fixture
def tenant(db):
    """A single active Tenant for generic test use."""
    from tests.factories import TenantFactory

    return TenantFactory()


@pytest.fixture
def user(db):
    """A regular (non-staff) active User with a valid mobile number."""
    from tests.factories import UserFactory

    return UserFactory()


@pytest.fixture
def admin_user(db):
    """A superuser — has is_staff=True and is_superuser=True."""
    from tests.factories import AdminUserFactory

    return AdminUserFactory()
