Coverage for tests/test_dates.py: 100%
10 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
« prev ^ index » next coverage.py v7.16.0, created at 2026-11-09 00:25 +0000
1from datetime import datetime, timezone 1abcdefg
3import pytest 1abcdefg
4import time_machine 1abcdefg
6from fastapi_cloud_cli.utils.dates import format_last_updated 1abcdefg
9@time_machine.travel(datetime(2026, 5, 22, 12, 0, tzinfo=timezone.utc), tick=False) 1abcdefg
10@pytest.mark.parametrize( 1abcdefg
11 ("updated_at", "expected"),
12 [
13 ("2026-05-22T11:59:30Z", "just now"),
14 ("2026-05-22T11:59:00Z", "1 minute ago"),
15 ("2026-05-22T11:30:00", "30 minutes ago"),
16 ("2026-05-22T10:00:00Z", "2 hours ago"),
17 ("2025-05-22T12:00:00Z", "1 year ago"),
18 ],
19)
20def test_format_last_updated_formats_relative_time( 1abcdefg
21 updated_at: str, expected: str
22) -> None:
23 assert format_last_updated(updated_at) == expected 1hijklmn
26def test_format_last_updated_returns_invalid_dates_unchanged() -> None: 1abcdefg
27 assert format_last_updated("not-a-date") == "not-a-date" 1opqrstu