Files
plex-playlist/backend/tests/integration/test_runtime_blackbox.py
copilotcoder 4af111fcdb
Some checks failed
CICD / Build and Publish CICD Base Image (push) Successful in 23s
CICD / Build and Push CICD Image (push) Failing after 13m16s
CICD / Backend Tests (push) Has been cancelled
CICD / Pre-commit Checks (push) Has been cancelled
CICD / Frontend Tests (push) Has been cancelled
CICD / Backend Doctests (push) Has been cancelled
CICD / Build and Publish Runtime Images (push) Has been cancelled
CICD / Runtime Black-Box Integration Tests (push) Has been cancelled
CICD / End-to-End Tests (push) Has been cancelled
Align CI and Poe test lanes with runtime compose flows
2026-07-06 16:51:39 -04:00

54 lines
1.7 KiB
Python

"""Runtime black-box integration tests executed over the container network."""
from __future__ import annotations
import json
import os
import urllib.error
import urllib.request
import pytest
BACKEND_BASE_URL = os.getenv("INTEGRATION_BACKEND_URL", "http://backend:8000").rstrip(
"/"
)
pytestmark = pytest.mark.integration
def _fetch(path: str) -> tuple[int, str]:
"""Fetch an endpoint and return status code and body text."""
url = f"{BACKEND_BASE_URL}{path}"
request = urllib.request.Request(url=url, method="GET")
try:
with urllib.request.urlopen(request, timeout=5) as response:
body = response.read().decode("utf-8", errors="replace")
return response.status, body
except urllib.error.HTTPError as exc:
body = exc.read().decode("utf-8", errors="replace")
return exc.code, body
def test_root_endpoint_runtime() -> None:
"""Runtime root endpoint should return backend API message."""
status, body = _fetch("/")
assert status == 200
payload = json.loads(body)
assert payload == {"message": "Plex Playlist Backend API"}
def test_health_endpoint_runtime() -> None:
"""Runtime health endpoint should report healthy database connectivity."""
status, body = _fetch("/health")
assert status == 200
payload = json.loads(body)
assert payload.get("status") == "healthy"
assert payload.get("database") == "connected"
def test_compatibility_endpoint_runtime() -> None:
"""Runtime compatibility endpoint should report policy check success."""
status, body = _fetch("/compatibility")
assert status == 200
payload = json.loads(body)
assert payload.get("ok") is True