deb04c9315
Sprint 0 completo del producto VMS-Sailor (Vessel Management System integrado para buques 30-40m). Brief de referencia en VMS_Sailor_v2_Parte_*.md (intacto). Core (vmssailor.core, 95.17% coverage, 99 tests verde): - ShipCoord: sistema naval x_pp/y_cl/z_bl frozen - Vessel, Deck, Bulkhead - Equipment, EquipmentModel, Sensor, EquipmentSpec - Tag, AlarmConfig, TagBinding, Scaling - CardInstance, Bus, Topology con validacion 21 puntos I/O AR-NMEA-IO-v1.0 - Alarm, PermissiveRule, Condition - Project agregado raiz con validacion cross-entity - Persistencia portable .vmsproj (SQLite) con roundtrip verificable Biblioteca curada seed (vmssailor.library): - systems_catalog.json completo (catalogo maestro Parte 1 sec 7) - 2 vessels: Sunseeker 76, Ferretti 850 - 2 motores: MTU 12V 2000 M96, Volvo D13-900 - 1 genset: Northern Lights M65C13 - yacht_motor_planeo.yaml (reglas heuristicas) - TODO marcado data_source=seed_estimate - requiere validacion datasheets Tools: - vms-validate-library: CLI valida biblioteca completa - vms-generate-test-project: CLI demo + verificacion roundtrip persistencia Design System + 8 mockups HTML estaticos: - docs/design_system.md (paleta Deep Ocean, gradientes, typography, motion) - docs/brand/ (logo + variantes SVG) - docs/mockups/splash, studio_main, runtime_overview, runtime_mimic_fuel (P&ID animado), runtime_alarms, runtime_trim (panel estrella con horizonte artificial), mobile_overview, mobile_trim - docs/mockups/index.html (galeria) Firmware (Sprint 12+ implementacion): - firmware/ar_nmea_io_v1/src/config/pinout.h con macros GPIO Decisiones autonomas documentadas en docs/decisions_sprint0.md. Stack: Python 3.11 + uv + Pydantic v2 + SQLite stdlib + hatchling + pytest 9 + ruff + mypy. Sin PySide6, FastAPI, Flutter ni firmware funcional (entran en sprints siguientes). Criterio de aceptacion Sprint 0: cumplido. - uv sync: OK - pytest: 99/99 verde - cov vmssailor.core: 95.17% (objetivo >=80%) - ruff: clean - vms-validate-library: OK - vms-generate-test-project: INTEGRIDAD OK Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
132 lines
3.4 KiB
Python
132 lines
3.4 KiB
Python
"""Tests del validador cross-entity."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from vmssailor.core import (
|
|
Bus,
|
|
BusRole,
|
|
CardInstance,
|
|
ChannelType,
|
|
Equipment,
|
|
Project,
|
|
Protocol,
|
|
Scaling,
|
|
ShipCoord,
|
|
SignalType,
|
|
SystemId,
|
|
Tag,
|
|
TagBinding,
|
|
Topology,
|
|
UnitSI,
|
|
Vessel,
|
|
VesselSubtype,
|
|
VesselType,
|
|
)
|
|
from vmssailor.core.validation import Severity, validate_project
|
|
|
|
|
|
def _make_vessel() -> Vessel:
|
|
return Vessel(
|
|
id="v",
|
|
name="V",
|
|
type=VesselType.YACHT_MOTOR,
|
|
subtype=VesselSubtype.PLANING,
|
|
length_overall_m=20.0,
|
|
beam_max_m=5.0,
|
|
draft_m=1.5,
|
|
)
|
|
|
|
|
|
def _basic_topology() -> Topology:
|
|
b = Bus(id="bm", name="bm", protocol=Protocol.MODBUS_RTU, physical_port="COM3")
|
|
c = CardInstance(
|
|
id="c1", slot_number=1, bus_id="bm",
|
|
bus_role=BusRole.MODBUS_SLAVE, modbus_address=1,
|
|
)
|
|
return Topology(buses=[b], cards=[c])
|
|
|
|
|
|
def test_orphan_system_warning() -> None:
|
|
p = Project(
|
|
id="p", name="p", vessel=_make_vessel(),
|
|
systems_enabled=[SystemId.MAIN_ENGINE, SystemId.WATERMAKER],
|
|
equipment=[],
|
|
topology=_basic_topology(),
|
|
)
|
|
r = validate_project(p)
|
|
assert r.ok()
|
|
assert any(i.code == "SYSTEM_WITHOUT_EQUIPMENT" for i in r.warnings)
|
|
|
|
|
|
def test_card_capacity_high_info() -> None:
|
|
topo = _basic_topology()
|
|
eq = Equipment(
|
|
id="eq", model_ref="m", tag_prefix="X",
|
|
display_name="x", location=ShipCoord(x_pp=5, y_cl=0, z_bl=1),
|
|
system_id=SystemId.MAIN_ENGINE,
|
|
)
|
|
|
|
# 4 AI = 100% (at-limit -> warning)
|
|
tags = []
|
|
for i in range(4):
|
|
tags.append(
|
|
Tag(
|
|
id=f"X.AI{i + 1}",
|
|
equipment_id="eq",
|
|
unit_si=UnitSI.BAR,
|
|
protocol=Protocol.MODBUS_RTU,
|
|
physical_binding=TagBinding(
|
|
card_id="c1",
|
|
channel_type=ChannelType.AI,
|
|
channel_number=i + 1,
|
|
signal_type=SignalType.SIG_4_20_MA,
|
|
scaling=Scaling(raw_min=4, raw_max=20, eng_min=0, eng_max=10),
|
|
),
|
|
)
|
|
)
|
|
p = Project(
|
|
id="p", name="p", vessel=_make_vessel(),
|
|
systems_enabled=[SystemId.MAIN_ENGINE],
|
|
equipment=[eq],
|
|
tags=tags,
|
|
topology=topo,
|
|
)
|
|
r = validate_project(p)
|
|
codes = {i.code for i in r.issues}
|
|
assert "CARD_CAPACITY_AT_LIMIT" in codes
|
|
|
|
|
|
def test_equipment_out_of_hull_warning() -> None:
|
|
eq = Equipment(
|
|
id="eq", model_ref="m", tag_prefix="X",
|
|
display_name="x",
|
|
location=ShipCoord(x_pp=100.0, y_cl=0.0, z_bl=1.0), # fuera del buque
|
|
system_id=SystemId.MAIN_ENGINE,
|
|
)
|
|
p = Project(
|
|
id="p", name="p", vessel=_make_vessel(),
|
|
systems_enabled=[SystemId.MAIN_ENGINE],
|
|
equipment=[eq],
|
|
topology=_basic_topology(),
|
|
)
|
|
r = validate_project(p)
|
|
codes = {i.code for i in r.issues}
|
|
assert "EQUIPMENT_OUT_OF_HULL" in codes
|
|
|
|
|
|
def test_validation_report_format() -> None:
|
|
p = Project(
|
|
id="p", name="p", vessel=_make_vessel(),
|
|
systems_enabled=[],
|
|
equipment=[],
|
|
topology=_basic_topology(),
|
|
)
|
|
r = validate_project(p)
|
|
assert "OK" in r.format() or "Total" in r.format()
|
|
|
|
|
|
def test_severity_values() -> None:
|
|
assert Severity.ERROR.value == "error"
|
|
assert Severity.WARNING.value == "warning"
|
|
assert Severity.INFO.value == "info"
|