# Live Smoke Test Pattern

## Marker Registration

In `pyproject.toml`:

```toml
[tool.pytest.ini_options]
markers = [
    "live: smoke tests against real provider APIs (requires API keys in env)",
]
```

## Test File Structure

```python
# tests/modules/streaming/test_live_provider_smoke.py
"""Smoke tests against real provider APIs. Skipped unless API keys are set."""

import os
import pytest

pytestmark = [pytest.mark.live]


# --- Real-Debrid ---

_RD_KEY = "REAL_DEBRID_API_KEY"

@pytest.mark.skipif(
    not os.environ.get(_RD_KEY),
    reason=f"requires {_RD_KEY} env var",
)
async def test_rd_direct_url_resolves(client, rd_account):
    """Known-good direct URL returns playable stream."""
    result = await resolve_direct_url(client, rd_account)
    assert result.stream_url.startswith("https://")
    assert result.filename
    assert isinstance(result.filesize, int)
    assert result.filesize > 0


@pytest.mark.skipif(
    not os.environ.get(_RD_KEY),
    reason=f"requires {_RD_KEY} env var",
)
async def test_rd_magnet_rejected_explicitly(client, rd_account):
    """Verify unsupported source type raises the right error."""
    with pytest.raises(UnsupportedStreamSourceError):
        await _resolve(client, rd_account.id, "magnet:?xt=urn:btih:...")
```

## Automation Workflow

```bash
# Default CI — skips all live tests
pytest -q
# => 210 passed, 5 skipped

# Live run with env vars
REAL_DEBRID_API_KEY=xxx ALL_DEBRID_API_KEY=xxx pytest -q -m live
# => 215 passed

# Per-provider live run
REAL_DEBRID_API_KEY=xxx pytest -q -m live -k real_debrid
```

## Session Example (Phase 5, streaming-app)

Added 5 live tests across 4 providers in `test_live_provider_smoke.py`:
- RD direct URL resolve (form-encoded POST with Bearer auth)
- AD direct URL resolve (query-param auth)
- PM magnet rejection (doesn't support magnets at all)
- TB magnet/IH torrent flow (form-encoded)
- TB unsupported source type rejection

Tests run via `pytest -q` = 210 passed, 5 skipped. Live run with all 4 env vars = all 215 passed.
