"""
Shared pytest configuration for backend integration tests.

Resolves the backend base URL + admin credentials from environment
variables so the same suite runs against:
  - the local FastAPI dev pod    (export BACKEND_URL=http://localhost:8001)
  - any Emergent preview pod     (export BACKEND_URL=https://nadiplayer-edit.preview.emergentagent.com)
  - the production cPanel/PHP    (default — https://4kmovies.vip/nadiplayer)

Precedence (first non-empty wins):
    BACKEND_URL  >  REACT_APP_BACKEND_URL  >  default
"""
import os


def _resolve_base_url() -> str:
    for key in ("BACKEND_URL", "REACT_APP_BACKEND_URL"):
        val = os.environ.get(key, "").strip()
        if val:
            return val.rstrip("/")
    # Production cPanel/PHP backend (default)
    return "https://4kmovies.vip/nadiplayer"


BASE_URL = _resolve_base_url()
ADMIN_USER = os.environ.get("ADMIN_USERNAME", "admin")
ADMIN_PASS = os.environ.get("ADMIN_PASSWORD", "admin123")
