Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
17 lines
579 B
Python
17 lines
579 B
Python
from datetime import UTC, datetime, timedelta, timezone
|
|
|
|
import pytest
|
|
|
|
from repo_manager.time import format_utc
|
|
|
|
|
|
def test_format_utc_normalizes_offsets_and_uses_z() -> None:
|
|
local = datetime(2026, 8, 21, 22, 30, tzinfo=timezone(timedelta(hours=2)))
|
|
|
|
assert format_utc(local) == "2026-08-21T20:30:00Z"
|
|
assert format_utc(local.astimezone(UTC)).endswith("Z")
|
|
|
|
|
|
def test_format_utc_rejects_naive_datetime() -> None:
|
|
with pytest.raises(ValueError, match="timezone-aware"):
|
|
format_utc(datetime(2026, 8, 21, 20, 30)) # noqa: DTZ001 - deliberate invalid input
|