"""Events test fixtures — direct module loading to avoid bp __init__ chains."""
from __future__ import annotations

import importlib.util
import sys


def _load(name: str, path: str):
    """Import a .py file directly, bypassing package __init__ chains."""
    if name in sys.modules:
        return sys.modules[name]
    spec = importlib.util.spec_from_file_location(name, path)
    mod = importlib.util.module_from_spec(spec)
    sys.modules[name] = mod
    spec.loader.exec_module(mod)
    return mod


# Ensure events/models is importable as 'models'
sys.path.insert(0, "/app/events")

# Pre-load target modules that would fail via normal package import
_load("events.bp.calendar.services.calendar_view",
      "/app/events/bp/calendar/services/calendar_view.py")
_load("events.bp.calendar.services.slots",
      "/app/events/bp/calendar/services/slots.py")
_load("events.bp.calendars.services.calendars",
      "/app/events/bp/calendars/services/calendars.py")
_load("events.bp.calendar_entries.routes",
      "/app/events/bp/calendar_entries/routes.py")
