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>
89 lines
2.3 KiB
Python
89 lines
2.3 KiB
Python
"""Tests de Equipment, EquipmentModel, Sensor."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from vmssailor.core import (
|
|
EquipmentCategory,
|
|
EquipmentModel,
|
|
EquipmentSpec,
|
|
Sensor,
|
|
SystemId,
|
|
UnitSI,
|
|
)
|
|
|
|
|
|
def test_sensor_basic() -> None:
|
|
s = Sensor(
|
|
id="oil_press",
|
|
name="Oil Pressure",
|
|
unit_si=UnitSI.BAR,
|
|
range_normal_min=3.0,
|
|
range_normal_max=5.5,
|
|
)
|
|
assert s.unit_si == UnitSI.BAR
|
|
|
|
|
|
def test_sensor_range_max_below_min_rejected() -> None:
|
|
with pytest.raises(ValidationError):
|
|
Sensor(
|
|
id="x",
|
|
name="X",
|
|
unit_si=UnitSI.BAR,
|
|
range_normal_min=5.0,
|
|
range_normal_max=2.0,
|
|
)
|
|
|
|
|
|
def test_equipment_model_with_sensors() -> None:
|
|
em = EquipmentModel(
|
|
id="mtu_test",
|
|
manufacturer="MTU",
|
|
model_name="Test",
|
|
category=EquipmentCategory.ENGINE_MAIN,
|
|
typical_systems=[SystemId.MAIN_ENGINE],
|
|
specs=EquipmentSpec(power_kw=1432, rpm_nominal=2450),
|
|
default_sensors=[
|
|
Sensor(id="rpm", name="RPM", unit_si=UnitSI.RPM),
|
|
Sensor(id="oil_press", name="Oil P", unit_si=UnitSI.BAR),
|
|
],
|
|
)
|
|
assert em.specs.power_kw == 1432
|
|
assert len(em.default_sensors) == 2
|
|
|
|
|
|
def test_equipment_model_duplicate_sensor_ids_rejected() -> None:
|
|
with pytest.raises(ValidationError):
|
|
EquipmentModel(
|
|
id="x",
|
|
manufacturer="X",
|
|
model_name="X",
|
|
category=EquipmentCategory.ENGINE_MAIN,
|
|
default_sensors=[
|
|
Sensor(id="rpm", name="RPM"),
|
|
Sensor(id="rpm", name="RPM dup"),
|
|
],
|
|
)
|
|
|
|
|
|
def test_equipment_instance(sample_equipment) -> None:
|
|
assert sample_equipment.tag_prefix == "ME_PORT"
|
|
assert sample_equipment.system_id == SystemId.MAIN_ENGINE
|
|
assert sample_equipment.installed
|
|
|
|
|
|
def test_equipment_invalid_tag_prefix_rejected() -> None:
|
|
with pytest.raises(ValidationError):
|
|
from vmssailor.core import Equipment, ShipCoord
|
|
|
|
Equipment(
|
|
id="x",
|
|
model_ref="m",
|
|
tag_prefix="lowercase_bad", # debe ser mayúsculas
|
|
display_name="X",
|
|
location=ShipCoord(x_pp=1.0, y_cl=0.0, z_bl=0.0),
|
|
system_id=SystemId.MAIN_ENGINE,
|
|
)
|