Spaces:
Sleeping
Sleeping
Download tests/conftest.py from benedictpepper/fitmate-api: direct link, hf CLI and curl.
- Browser
- Download file 929 Bytes
-
https://huggingface.co/spaces/benedictpepper/fitmate-api/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/benedictpepper/fitmate-api/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/benedictpepper/fitmate-api/resolve/main/tests/conftest.py
929 Bytes
| """ | |
| conftest.py β Shared pytest fixtures for FitMate backend tests. | |
| Provides: client (TestClient), valid_token (JWT), auth_headers (Bearer header dict) | |
| """ | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| def client(): | |
| """FastAPI TestClient for the main app.""" | |
| import sys | |
| import os | |
| backend_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| if backend_dir not in sys.path: | |
| sys.path.insert(0, backend_dir) | |
| from main import app | |
| return TestClient(app) | |
| def valid_token(): | |
| """Generate a valid admin JWT for testing protected routes.""" | |
| from utils.auth import create_access_token | |
| return create_access_token(subject="admin") | |
| def auth_headers(valid_token): | |
| """HTTP Authorization header dict with valid Bearer token.""" | |
| return {"Authorization": f"Bearer {valid_token}"} | |