Skip to content

Commit 8a616ea

Browse files
feat(brass): centralize table config and refactor report generation; restore minimal shim for tests
1 parent a27d165 commit 8a616ea

3 files changed

Lines changed: 65 additions & 4 deletions

File tree

src/brass/brass_manager.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from common.html_report_generator import HTMLReportGenerator
1616
from common.reporting.table_builder import build_table_html
17+
from common.reporting.table_configurations import BRASS_TABLE_CONFIGURATIONS # type: ignore
1718

1819

1920
class BrassManager:
@@ -77,9 +78,9 @@ def generate_brass_report_html(self) -> str:
7778
header = self.html_generator.generar_header_moderno(
7879
"INFORME DE AVISOS DE EQUIPOS DE MEDIDA FUERA DE CALIBRACIÓN"
7980
)
80-
table_html = build_table_html(
81-
"Equipos de Medida Fuera de Calibración", data, sort_headers=True
82-
)
81+
# Usar configuración centralizada (primer y único key por ahora)
82+
cfg = BRASS_TABLE_CONFIGURATIONS["equipment_out_of_calibration"]
83+
table_html = build_table_html(cfg["title"], data, sort_headers=True)
8384
footer = self.html_generator.generar_footer_moderno()
8485
html = header + table_html + footer
8586
self.logger.info(

src/brass/run_brass.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Shim mínimo para compatibilidad de tests (import src.brass.run_brass).
2+
3+
Delegación al runner real en scripts/run_brass.py evitando duplicar lógica.
4+
Tests parchean BrassTask aquí; por eso se reexporta.
5+
"""
6+
from __future__ import annotations
7+
8+
import sys
9+
from pathlib import Path
10+
11+
PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent
12+
SRC_DIR = PROJECT_ROOT / "src"
13+
if str(SRC_DIR) not in sys.path:
14+
sys.path.insert(0, str(SRC_DIR))
15+
16+
try: # pragma: no cover
17+
from scripts.run_brass import parse_args, main # type: ignore
18+
except Exception: # pragma: no cover - fallback mínimo
19+
def parse_args(argv=None): # type: ignore
20+
import argparse
21+
p = argparse.ArgumentParser(description="Runner BRASS (shim)")
22+
p.add_argument("--force", action="store_true")
23+
p.add_argument("--dry-run", action="store_true")
24+
return p.parse_args(argv)
25+
26+
def main(argv=None): # type: ignore
27+
from brass.brass_task import BrassTask # local import
28+
from common.utils import execute_task_with_standard_boilerplate
29+
args = parse_args(argv)
30+
task = BrassTask()
31+
code = execute_task_with_standard_boilerplate(
32+
"BRASS", task, force=args.force, dry_run=getattr(args, "dry_run", False)
33+
)
34+
sys.exit(code)
35+
36+
from brass.brass_task import BrassTask # type: ignore # reexport para monkeypatch
37+
38+
__all__ = ["BrassTask", "parse_args", "main"]
39+
40+
if __name__ == "__main__": # pragma: no cover
41+
main()

src/common/reporting/table_configurations.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,23 @@
221221
# },
222222
}
223223

224-
__all__ = ["TABLE_CONFIGURATIONS", "AGEDYS_TABLE_CONFIGURATIONS"]
224+
BRASS_TABLE_CONFIGURATIONS = {
225+
"equipment_out_of_calibration": {
226+
"title": "Equipos de Medida Fuera de Calibración",
227+
"columns": [
228+
{"header": "ID", "field": "IDEquipoMedida"},
229+
{"header": "Nombre", "field": "NOMBRE"},
230+
{"header": "Nº Serie", "field": "NS"},
231+
{"header": "PN", "field": "PN"},
232+
{"header": "Marca", "field": "MARCA"},
233+
{"header": "Modelo", "field": "MODELO"},
234+
{"header": "Fecha Fin Calibración", "field": "FechaFinCalibracion", "format": "date"},
235+
],
236+
}
237+
}
238+
239+
__all__ = [
240+
"TABLE_CONFIGURATIONS",
241+
"AGEDYS_TABLE_CONFIGURATIONS",
242+
"BRASS_TABLE_CONFIGURATIONS",
243+
]

0 commit comments

Comments
 (0)