"""Regression tests for the application's timestamp convention.""" import ast from datetime import UTC, datetime from pathlib import Path from app.time_utils import utc_now_naive def test_utc_now_naive_is_an_explicit_utc_value(): before = datetime.now(UTC).replace(tzinfo=None) actual = utc_now_naive() after = datetime.now(UTC).replace(tzinfo=None) assert actual.tzinfo is None assert before <= actual <= after def test_application_does_not_call_deprecated_utcnow(): app_root = Path(__file__).parents[1] / 'app' offenders = [] for path in app_root.rglob('*.py'): tree = ast.parse(path.read_text(encoding='utf-8'), filename=str(path)) for node in ast.walk(tree): if isinstance(node, ast.Attribute) and node.attr == 'utcnow': offenders.append(f'{path.relative_to(app_root)}:{node.lineno}') assert offenders == []