Files
animaltrack/tests/test_constants.py
Petru Paler d8910d6571 feat: add database module with connection factory and transactions
Implements Step 1.2:
- constants.py: END_OF_TIME_UTC = 32503680000000 (year 3000 sentinel)
- db.py: get_db() with pragmas (WAL, synchronous=FULL, foreign_keys, busy_timeout)
- db.py: transaction() context manager with BEGIN IMMEDIATE

Includes 12 TDD tests for pragmas, commit/rollback, and concurrent writes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 17:58:29 +00:00

34 lines
1.1 KiB
Python

# ABOUTME: Tests for the constants module.
# ABOUTME: Validates sentinel values used throughout the application.
import datetime
class TestEndOfTimeUtc:
"""Test the END_OF_TIME_UTC sentinel constant."""
def test_end_of_time_value(self):
"""END_OF_TIME_UTC should equal 32503680000000 (ms epoch for year 3000)."""
from animaltrack.constants import END_OF_TIME_UTC
assert END_OF_TIME_UTC == 32503680000000
def test_end_of_time_represents_year_3000(self):
"""END_OF_TIME_UTC should represent January 1, 3000 00:00:00 UTC."""
from animaltrack.constants import END_OF_TIME_UTC
# Convert ms to seconds for datetime
dt = datetime.datetime.fromtimestamp(END_OF_TIME_UTC / 1000, tz=datetime.UTC)
assert dt.year == 3000
assert dt.month == 1
assert dt.day == 1
assert dt.hour == 0
assert dt.minute == 0
assert dt.second == 0
def test_end_of_time_is_integer(self):
"""END_OF_TIME_UTC should be an integer (ms precision)."""
from animaltrack.constants import END_OF_TIME_UTC
assert isinstance(END_OF_TIME_UTC, int)