feat: poblar scaffold inicial del shape rest-api/python
Some checks failed
__APP_NAME__ — build & deploy / build (push) Failing after 0s
__APP_NAME__ — build & deploy / helm-deploy (push) Has been skipped

Reemplaza el placeholder mínimo previo por el scaffold canónico del
golden path rest-api/python (entry point para tier free-trial):

- code/app/main.py — FastAPI con /health (sin DB), /metrics, middleware
  correlation_id, settings Pydantic
- code/tests/ — pytest + httpx TestClient (sin testcontainers, sin Docker)
- helm/APP_NAME/ — chart minimal: Deployment, Service, IngressRoute,
  NetworkPolicy. SIN Job Alembic, SIN ServiceMonitor, SIN claim de BD
- coralware-shape.yaml — shapeVersion 1.0.0, minTier free-trial,
  promotionPath -> web-backend-python cuando se requiera persistencia
- .gitea/workflows/APP_NAME-build.yaml — invoca reusable workflow ADR-038
  + job helm-deploy con KUBECONFIG_TENANT_B64

Diferencias con web-backend/python: sin alembic, sin BD, sin
testcontainers, NetworkPolicy sin acceso a ns-addons.

Placeholders __APP_NAME__, __TIER__, __TENANT_ID__, __TENANT_ID_NODASHES__
serán sustituidos server-side por repo-provisioner.

El openspec/ del golden path NO se sincroniza al repo Gitea (gobernanza
interna de Coralware).

Refs: ADR-027 (Golden Paths), ADR-038 (CI), ADR-053 (referencia anatomía).
This commit is contained in:
2026-05-06 17:57:04 -05:00
parent 78c4c0069b
commit 99544639e6
23 changed files with 719 additions and 32 deletions

0
code/tests/__init__.py Normal file
View File

21
code/tests/conftest.py Normal file
View File

@@ -0,0 +1,21 @@
"""
Fixtures para los tests del shape rest-api/python.
A diferencia de web-backend/python (que levanta MariaDB con testcontainers),
este shape no tiene persistencia — los tests corren sin Docker.
"""
from collections.abc import Iterator
import pytest
from fastapi.testclient import TestClient
@pytest.fixture
def client() -> Iterator[TestClient]:
"""TestClient con la app cargada. Sin BD, sin contenedores externos."""
from app.main import create_app
app = create_app()
with TestClient(app) as c:
yield c

26
code/tests/test_main.py Normal file
View File

@@ -0,0 +1,26 @@
"""Cubre los endpoints obligatorios del shape: /health y /metrics."""
from fastapi.testclient import TestClient
def test_health_returns_200_ok(client: TestClient) -> None:
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "ok"}
def test_health_propagates_correlation_id(client: TestClient) -> None:
cid = "test-cid-12345"
response = client.get("/health", headers={"X-Correlation-ID": cid})
assert response.headers.get("X-Correlation-ID") == cid
def test_health_generates_correlation_id_when_absent(client: TestClient) -> None:
response = client.get("/health")
assert response.headers.get("X-Correlation-ID")
def test_metrics_endpoint_serves_prometheus_format(client: TestClient) -> None:
response = client.get("/metrics")
assert response.status_code == 200
assert "text/plain" in response.headers.get("content-type", "")