Files
alro65 deb04c9315 sprint-0: fundaciones VMS-Sailor
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>
2026-05-17 07:26:06 -04:00

70 lines
2.0 KiB
Python

"""Tests del sistema de coordenadas naval."""
from __future__ import annotations
import pytest
from pydantic import ValidationError
from vmssailor.core import ShipCoord
def test_construct_valid() -> None:
c = ShipCoord(x_pp=10.0, y_cl=-1.5, z_bl=2.0)
assert c.x_pp == 10.0
assert c.y_cl == -1.5
assert c.z_bl == 2.0
def test_frozen() -> None:
c = ShipCoord(x_pp=10.0, y_cl=0.0, z_bl=1.0)
with pytest.raises(ValidationError):
c.x_pp = 99.0 # type: ignore[misc]
def test_as_tuple() -> None:
c = ShipCoord(x_pp=1.0, y_cl=2.0, z_bl=3.0)
assert c.as_tuple() == (1.0, 2.0, 3.0)
def test_is_starboard_port_centerline() -> None:
starboard = ShipCoord(x_pp=5.0, y_cl=1.0, z_bl=0.0)
port = ShipCoord(x_pp=5.0, y_cl=-1.0, z_bl=0.0)
centerline = ShipCoord(x_pp=5.0, y_cl=0.0, z_bl=0.0)
assert starboard.is_starboard()
assert not starboard.is_port()
assert not starboard.is_centerline()
assert port.is_port()
assert not port.is_starboard()
assert centerline.is_centerline()
assert not centerline.is_starboard()
assert not centerline.is_port()
def test_distance_to() -> None:
a = ShipCoord(x_pp=0.0, y_cl=0.0, z_bl=0.0)
b = ShipCoord(x_pp=3.0, y_cl=4.0, z_bl=0.0)
assert a.distance_to(b) == pytest.approx(5.0)
def test_out_of_range_rejected() -> None:
with pytest.raises(ValidationError):
ShipCoord(x_pp=999.0, y_cl=0.0, z_bl=0.0)
with pytest.raises(ValidationError):
ShipCoord(x_pp=10.0, y_cl=999.0, z_bl=0.0)
with pytest.raises(ValidationError):
ShipCoord(x_pp=10.0, y_cl=0.0, z_bl=-999.0)
def test_extra_fields_forbidden() -> None:
with pytest.raises(ValidationError):
ShipCoord(x_pp=1.0, y_cl=0.0, z_bl=0.0, foo="bar") # type: ignore[call-arg]
def test_str_representation() -> None:
c = ShipCoord(x_pp=10.0, y_cl=-1.5, z_bl=2.0)
s = str(c)
assert "10.00" in s
assert "-1.50" in s
assert "+2.00" in s
assert "[m]" in s