Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
28 lines
769 B
Python
28 lines
769 B
Python
import unittest
|
|
|
|
from sched.ids import IdGenerator
|
|
|
|
|
|
class IdGeneratorTests(unittest.TestCase):
|
|
def test_first_ids(self):
|
|
gen = IdGenerator()
|
|
self.assertEqual([gen.next_id() for _ in range(3)], ["j-001", "j-002", "j-003"])
|
|
|
|
def test_ids_are_hex(self):
|
|
gen = IdGenerator(start=0x0A2)
|
|
self.assertEqual(gen.next_id(), "j-0a3")
|
|
|
|
def test_ids_are_unique_for_a_while(self):
|
|
gen = IdGenerator()
|
|
ids = [gen.next_id() for _ in range(2000)]
|
|
self.assertEqual(len(set(ids)), 2000)
|
|
|
|
def test_ids_sort_in_creation_order_within_a_page(self):
|
|
gen = IdGenerator()
|
|
ids = [gen.next_id() for _ in range(200)]
|
|
self.assertEqual(ids, sorted(ids))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|