"""Tests para format_iso8601."""

import sys
import os

sys.path.insert(0, os.path.dirname(__file__))

from datetime import datetime, timezone, timedelta
from format_iso8601 import format_iso8601


def test_datetime_naive_formateado_como_utc():
    dt = datetime(2026, 2, 21, 13, 20, 23, 147000)
    result = format_iso8601(dt)
    assert result == "2026-02-21T13:20:23.147Z"


def test_datetime_con_timezone_convertido_a_utc():
    tz8 = timezone(timedelta(hours=8))
    dt = datetime(2026, 2, 21, 21, 20, 23, 147000, tzinfo=tz8)
    result = format_iso8601(dt)
    assert result == "2026-02-21T13:20:23.147Z"


def test_datetime_utc_sin_conversion():
    dt = datetime(2026, 6, 15, 9, 0, 0, 500000, tzinfo=timezone.utc)
    result = format_iso8601(dt)
    assert result == "2026-06-15T09:00:00.500Z"
