# ABOUTME: Tests for ULID generation utility. # ABOUTME: Verifies that generated IDs are valid 26-character ULIDs and unique. from animaltrack.id_gen import generate_id class TestGenerateId: """Tests for the generate_id function.""" def test_returns_string(self): """generate_id returns a string.""" result = generate_id() assert isinstance(result, str) def test_returns_26_characters(self): """generate_id returns exactly 26 characters (ULID format).""" result = generate_id() assert len(result) == 26 def test_returns_unique_ids(self): """generate_id returns unique IDs on each call.""" ids = [generate_id() for _ in range(100)] assert len(set(ids)) == 100 def test_ulid_is_uppercase_alphanumeric(self): """ULID contains only uppercase letters and digits (Crockford base32).""" result = generate_id() # Crockford base32 excludes I, L, O, U valid_chars = set("0123456789ABCDEFGHJKMNPQRSTVWXYZ") assert all(c in valid_chars for c in result)