Notebook de las rutas de indicadores de CaMa
Siembra CaCu, CaMa y TEA en bases temporales, revisa la lista, una figura por semestre y por mes, los errores 400 y 404, y que /cacu y /tea siguen igual. Pruebas: Core 25 passed; Persistance 31 passed; indicadores_kit 564 passed, 2 skipped; WebApi 74 passed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,692 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "08979bf1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Qué revisa este notebook.** Las rutas de indicadores de CaMa (tarea WA-2), el análogo de las de TEA: `webapi/indicadores.py` registra en el blueprint `/cama`\n",
|
||||
"\n",
|
||||
"| Ruta | Qué devuelve |\n",
|
||||
"|---|---|\n",
|
||||
"| `GET /cama/indicadores` | id, título, contrato, figuras y tipos de periodo que publica cada indicador |\n",
|
||||
"| `GET /cama/indicadores/<id>/figuras/<figura>?periodos=&tema=` | JSON de Plotly; 404 si el indicador, la figura o el reporte no existen; 400 si el tema o los periodos están mal |\n",
|
||||
"\n",
|
||||
"Por qué: antes solo TEA servía indicadores y su lógica vivía en su blueprint; ahora es un solo código para todos los proyectos. Los periodos se validan contra los `tipos_periodo` que publica la definición (semestre `AAAA-S1`, mes `AAAA-MM`).\n",
|
||||
"\n",
|
||||
"Todo corre en una carpeta temporal, con la app de Flask dentro del proceso (cliente de pruebas, sin servidor); no deja archivos en el repositorio. Cada sección termina en `assert`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "d5ad084c",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:12.636812Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:12.636595Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:13.532062Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:13.531521Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import tempfile\n",
|
||||
"from datetime import date\n",
|
||||
"from pathlib import Path\n",
|
||||
"\n",
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"import apoyo\n",
|
||||
"from indicadores_kit.pasos import calcular_periodos, cargar, fabrica_por_defecto, preparar_registro, vistas\n",
|
||||
"from indicadores_kit.registry.measures import leer_measure, ruta_de_measure\n",
|
||||
"\n",
|
||||
"carpeta = Path(tempfile.mkdtemp(prefix=\"cama_ind_\"))\n",
|
||||
"parametros = apoyo.parametros_sin_supresion(carpeta)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def sembrar(proyecto):\n",
|
||||
" \"\"\"Base migrada con staging sintético, cargada, con `<proyecto>_eu8` calculado en semestres y meses.\"\"\"\n",
|
||||
" apoyo.montar(proyecto, carpeta)\n",
|
||||
" cargar(proyecto)\n",
|
||||
" vistas(fabrica_por_defecto(proyecto), proyecto)\n",
|
||||
" preparar_registro(proyecto, 2025, 2025, ruta=parametros, tipos=(\"semestre\", \"mes\"))\n",
|
||||
" medida = leer_measure(ruta_de_measure(proyecto, f\"{proyecto}_eu8\"))\n",
|
||||
" return {\n",
|
||||
" tipo: len(calcular_periodos(proyecto, medida, tipo, date(2025, 1, 1), date(2026, 1, 1), permitir_sin_definir=True))\n",
|
||||
" for tipo in (\"semestre\", \"mes\")\n",
|
||||
" }"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8a047caf",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 1. Sembrar CaCu, CaMa y TEA\n",
|
||||
"\n",
|
||||
"CaMa es lo que se revisa; CaCu y TEA se siembran para comprobar al final que siguen respondiendo."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "2d1f6b64",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:13.534349Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:13.534069Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:14.164492Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:14.163897Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Context impl SQLiteImpl.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Will assume non-transactional DDL.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade -> 79fe432d52a2, create cacu tables\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 79fe432d52a2 -> cbb31acf322d, add biometria hematica\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade cbb31acf322d -> 9952833a0048, add indicadores_kit tables\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 9952833a0048 -> b4a35a200913, add dim_fecha and dim_grupo_edad\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade b4a35a200913 -> 04fa57d42fec, add indicador_definicion\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 04fa57d42fec -> 1b350354d5ed, add measure_report.parametros_sha\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 1b350354d5ed -> cbd8fed23729, measure_report kit_version replaces sql_sha\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade cbd8fed23729 -> 8e7534131c73, add result tables\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Context impl SQLiteImpl.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Will assume non-transactional DDL.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade -> 61636717f659, create cama tables\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 61636717f659 -> c6939a6f23da, add biometria hematica\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade c6939a6f23da -> 0616858b7434, add indicadores_kit tables\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 0616858b7434 -> 1006aa43f896, add dim_fecha and dim_grupo_edad\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 1006aa43f896 -> b47d340c39f9, add indicador_definicion\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade b47d340c39f9 -> 2568e85ae55a, add measure_report.parametros_sha\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade 2568e85ae55a -> b3ef4834fd39, measure_report kit_version replaces sql_sha\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"INFO [alembic.runtime.migration] Running upgrade b3ef4834fd39 -> 4a8f75c95c04, add result tables\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>cacu</th>\n",
|
||||
" <th>cama</th>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>reportes por tipo</th>\n",
|
||||
" <th></th>\n",
|
||||
" <th></th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>semestre</th>\n",
|
||||
" <td>2</td>\n",
|
||||
" <td>2</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>mes</th>\n",
|
||||
" <td>12</td>\n",
|
||||
" <td>12</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" cacu cama\n",
|
||||
"reportes por tipo \n",
|
||||
"semestre 2 2\n",
|
||||
"mes 12 12"
|
||||
]
|
||||
},
|
||||
"execution_count": 2,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"calculados = {p: sembrar(p) for p in (\"cacu\", \"cama\")}\n",
|
||||
"pd.DataFrame(calculados).rename_axis(\"reportes por tipo\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "4b139a71",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:14.166372Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:14.166264Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:16.964747Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:16.963671Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"assert calculados[\"cacu\"] == calculados[\"cama\"] == {\"semestre\": 2, \"mes\": 12}\n",
|
||||
"\n",
|
||||
"from indicadores_kit.tea import fixtures as fixtures_tea\n",
|
||||
"from persistance.db import get_tea_engine\n",
|
||||
"from persistance.settings import settings\n",
|
||||
"\n",
|
||||
"settings.tea_database_url = f\"sqlite:///{carpeta / 'tea.db'}\"\n",
|
||||
"get_tea_engine.cache_clear()\n",
|
||||
"assert len(fixtures_tea.base_de_prueba(get_tea_engine())) == 18"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "26625d23",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 2. Levantar la app"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "43b83c90",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:16.967133Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:16.966937Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:17.182927Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:17.182429Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from webapi import create_app\n",
|
||||
"\n",
|
||||
"app = create_app()\n",
|
||||
"app.config.update(TESTING=True)\n",
|
||||
"cliente = app.test_client()\n",
|
||||
"assert cliente.get(\"/health\").status_code == 200"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a4b9236d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 3. `GET /cama/indicadores`\n",
|
||||
"\n",
|
||||
"La lista sale de las definiciones del kit. CaMa no tiene ficha: su figura es un punto por periodo."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "a7b6352a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:17.185036Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:17.184883Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:17.193594Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:17.192992Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>contrato</th>\n",
|
||||
" <th>figuras</th>\n",
|
||||
" <th>id</th>\n",
|
||||
" <th>tipos_periodo</th>\n",
|
||||
" <th>titulo</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>C1</td>\n",
|
||||
" <td>[fig_c1_puntos]</td>\n",
|
||||
" <td>cama_eu8</td>\n",
|
||||
" <td>[semestre, mes]</td>\n",
|
||||
" <td>Proporción de exámenes técnicamente aceptables</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" contrato figuras id tipos_periodo \\\n",
|
||||
"0 C1 [fig_c1_puntos] cama_eu8 [semestre, mes] \n",
|
||||
"\n",
|
||||
" titulo \n",
|
||||
"0 Proporción de exámenes técnicamente aceptables "
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"respuesta = cliente.get(\"/cama/indicadores\")\n",
|
||||
"assert respuesta.status_code == 200\n",
|
||||
"(fila,) = respuesta.get_json()\n",
|
||||
"assert fila[\"id\"] == \"cama_eu8\"\n",
|
||||
"assert fila[\"contrato\"] == \"C1\" and fila[\"figuras\"] == [\"fig_c1_puntos\"]\n",
|
||||
"assert fila[\"tipos_periodo\"] == [\"semestre\", \"mes\"]\n",
|
||||
"pd.DataFrame([fila])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8c8c5a96",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 4. Una figura por semestre y una por mes\n",
|
||||
"\n",
|
||||
"Sin `?periodos=` se usan los periodos con reporte del primer tipo que publica la definición (semestre). Con meses, se piden explícitos."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "bdacb5d2",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:17.195892Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:17.195747Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:17.473353Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:17.472652Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(['2025-S1', '2025-S2'], ['2025-01', '2025-02', '2025-03'])"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def eje_x(respuesta):\n",
|
||||
" return sorted({x for trazo in respuesta.get_json()[\"data\"] for x in trazo[\"x\"]})\n",
|
||||
"\n",
|
||||
"base = \"/cama/indicadores/cama_eu8/figuras/fig_c1_puntos\"\n",
|
||||
"semestres = cliente.get(base)\n",
|
||||
"assert semestres.status_code == 200 and semestres.mimetype == \"application/json\"\n",
|
||||
"assert eje_x(semestres) == [\"2025-S1\", \"2025-S2\"]\n",
|
||||
"meses = cliente.get(base + \"?periodos=2025-01,2025-02,2025-03&tema=oscuro\")\n",
|
||||
"assert meses.status_code == 200\n",
|
||||
"assert eje_x(meses) == [\"2025-01\", \"2025-02\", \"2025-03\"]\n",
|
||||
"eje_x(semestres), eje_x(meses)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "209f6915",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 5. Los errores\n",
|
||||
"\n",
|
||||
"400: tema o periodos mal formados, un tipo que el indicador no publica o tipos mezclados. 404: indicador o figura desconocidos, o un periodo sin reporte."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "3aaa513e",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:17.474906Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:17.474786Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:17.485833Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:17.485313Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>caso</th>\n",
|
||||
" <th>código</th>\n",
|
||||
" <th>error</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>tema desconocido</td>\n",
|
||||
" <td>400</td>\n",
|
||||
" <td>tema desconocido 'rojo'; use claro u oscuro</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>periodo mal formado</td>\n",
|
||||
" <td>400</td>\n",
|
||||
" <td>Periodos mal formados: '2025-1'; este indicado...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>tipo que no publica</td>\n",
|
||||
" <td>400</td>\n",
|
||||
" <td>Periodos mal formados: '2025-T1'; este indicad...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>tipos mezclados</td>\n",
|
||||
" <td>400</td>\n",
|
||||
" <td>Periodos de tipos distintos: '2025-S1,2025-03'...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>indicador desconocido</td>\n",
|
||||
" <td>404</td>\n",
|
||||
" <td>indicador desconocido</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>5</th>\n",
|
||||
" <td>figura de otro contrato</td>\n",
|
||||
" <td>404</td>\n",
|
||||
" <td>figura 'fig_c2_apiladas' no es del contrato C1</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>6</th>\n",
|
||||
" <td>semestre sin reporte</td>\n",
|
||||
" <td>404</td>\n",
|
||||
" <td>No hay reporte de cama/CAMA_EU8 0.1.0 para 203...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>7</th>\n",
|
||||
" <td>mes sin reporte</td>\n",
|
||||
" <td>404</td>\n",
|
||||
" <td>No hay reporte de cama/CAMA_EU8 0.1.0 para 203...</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" caso código \\\n",
|
||||
"0 tema desconocido 400 \n",
|
||||
"1 periodo mal formado 400 \n",
|
||||
"2 tipo que no publica 400 \n",
|
||||
"3 tipos mezclados 400 \n",
|
||||
"4 indicador desconocido 404 \n",
|
||||
"5 figura de otro contrato 404 \n",
|
||||
"6 semestre sin reporte 404 \n",
|
||||
"7 mes sin reporte 404 \n",
|
||||
"\n",
|
||||
" error \n",
|
||||
"0 tema desconocido 'rojo'; use claro u oscuro \n",
|
||||
"1 Periodos mal formados: '2025-1'; este indicado... \n",
|
||||
"2 Periodos mal formados: '2025-T1'; este indicad... \n",
|
||||
"3 Periodos de tipos distintos: '2025-S1,2025-03'... \n",
|
||||
"4 indicador desconocido \n",
|
||||
"5 figura 'fig_c2_apiladas' no es del contrato C1 \n",
|
||||
"6 No hay reporte de cama/CAMA_EU8 0.1.0 para 203... \n",
|
||||
"7 No hay reporte de cama/CAMA_EU8 0.1.0 para 203... "
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"casos = {\n",
|
||||
" \"tema desconocido\": (base + \"?tema=rojo\", 400),\n",
|
||||
" \"periodo mal formado\": (base + \"?periodos=2025-1\", 400),\n",
|
||||
" \"tipo que no publica\": (base + \"?periodos=2025-T1\", 400),\n",
|
||||
" \"tipos mezclados\": (base + \"?periodos=2025-S1,2025-03\", 400),\n",
|
||||
" \"indicador desconocido\": (\"/cama/indicadores/NO_EXISTE/figuras/fig_c1_puntos\", 404),\n",
|
||||
" \"figura de otro contrato\": (\"/cama/indicadores/cama_eu8/figuras/fig_c2_apiladas\", 404),\n",
|
||||
" \"semestre sin reporte\": (base + \"?periodos=2030-S1\", 404),\n",
|
||||
" \"mes sin reporte\": (base + \"?periodos=2030-11\", 404),\n",
|
||||
"}\n",
|
||||
"filas = []\n",
|
||||
"for nombre, (ruta, esperado) in casos.items():\n",
|
||||
" respuesta = cliente.get(ruta)\n",
|
||||
" assert respuesta.status_code == esperado, (nombre, respuesta.status_code)\n",
|
||||
" assert \"error\" in respuesta.get_json()\n",
|
||||
" filas.append({\"caso\": nombre, \"código\": respuesta.status_code, \"error\": respuesta.get_json()[\"error\"]})\n",
|
||||
"pd.DataFrame(filas)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "83cc8e7d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 6. CaCu y TEA siguen respondiendo\n",
|
||||
"\n",
|
||||
"El código es el mismo para los tres proyectos; el blueprint de CaMa no cambió a los otros."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "277c2d8a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2026-10-11T06:29:17.487716Z",
|
||||
"iopub.status.busy": "2026-10-11T06:29:17.487598Z",
|
||||
"iopub.status.idle": "2026-10-11T06:29:17.603918Z",
|
||||
"shell.execute_reply": "2026-10-11T06:29:17.603263Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"404"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"cacu = cliente.get(\"/cacu/indicadores/cacu_eu8/figuras/fig_c1_puntos?periodos=2025-03\")\n",
|
||||
"assert cacu.status_code == 200\n",
|
||||
"lista = cliente.get(\"/tea/indicadores\").get_json()\n",
|
||||
"assert len(lista) == 18\n",
|
||||
"tea = next(f for f in lista if f[\"id\"] == \"K01_evaluacion_3_meses\")\n",
|
||||
"figura = cliente.get(f\"/tea/indicadores/{tea['id']}/figuras/{tea['figuras'][0]}?periodos=2025-S1,2025-S2\")\n",
|
||||
"assert figura.status_code == 200 and \"data\" in figura.get_json()\n",
|
||||
"cliente.get(\"/cacu/indicadores/NO_EXISTE/figuras/fig_c1_puntos\").status_code"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.14.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user