"""Tests de generación de IDs.""" from __future__ import annotations import pytest from vmssailor.shared.ids import ( make_alarm_config_id, make_alarm_instance_id, make_project_id, make_tag_id, new_uuid, ) def test_make_tag_id_basic() -> None: assert make_tag_id("ME_PORT", "oil_press") == "ME_PORT.OIL_PRESS" def test_make_tag_id_rejects_lowercase_prefix() -> None: with pytest.raises(ValueError): make_tag_id("me_port", "oil_press") def test_make_tag_id_rejects_uppercase_sensor() -> None: with pytest.raises(ValueError): make_tag_id("ME_PORT", "OIL_PRESS") def test_alarm_config_id() -> None: cid = make_alarm_config_id("ME_PORT.OIL_PRESS", "low") assert cid == "ME_PORT.OIL_PRESS.LOW" def test_alarm_instance_id_deterministic() -> None: a = make_alarm_instance_id("ME_PORT.OIL_PRESS", "ME_PORT.OIL_PRESS.LOW", 1234567890.0) assert a.startswith("alm.ME_PORT.OIL_PRESS.LOW.") def test_new_uuid_unique() -> None: a = new_uuid() b = new_uuid() assert a != b assert len(a) == 36 # UUID canonical def test_project_id_normalization() -> None: pid = make_project_id("Acme Yachts S.A.", "Sunseeker_76") # Espacios y puntuación se normalizan assert pid == "acme_yachts_s_a___sunseeker_76" or pid.startswith("acme_yachts_s_a") assert "__" in pid # separador customer__vessel