""" tests/test_wheeling.py ----------------------- Tests for core/wheeling.py — full-cover wheel generation. """ import pytest from core.wheeling import wheel_full, wheel_count, MAX_TICKETS # ── wheel_count ─────────────────────────────────────────────────────────────── def test_wheel_count_basic(): assert wheel_count([1, 2, 3, 4, 5, 6], 5) == 6 # C(6,5) def test_wheel_count_exact_pick(): assert wheel_count([1, 2, 3, 4, 5], 5) == 1 # C(5,5) def test_wheel_count_larger(): assert wheel_count(list(range(1, 10)), 5) == 126 # C(9,5) def test_wheel_count_k_zero_returns_zero(): assert wheel_count([1, 2, 3, 4, 5], 0) == 0 def test_wheel_count_k_exceeds_n_returns_zero(): assert wheel_count([1, 2, 3], 5) == 0 def test_wheel_count_deduplicates_input(): assert wheel_count([1, 1, 2, 3, 4, 5], 5) == 1 # C(5,5) after dedup # ── wheel_full — valid cases ────────────────────────────────────────────────── def test_wheel_full_ticket_count(): tickets = wheel_full([1, 2, 3, 4, 5, 6], 5) assert len(tickets) == 6 def test_wheel_full_single_ticket(): tickets = wheel_full([5, 14, 22, 36, 69], 5) assert len(tickets) == 1 assert tickets[0] == [5, 14, 22, 36, 69] def test_wheel_full_each_ticket_sorted(): tickets = wheel_full([10, 3, 7, 1, 5, 2], 4) for t in tickets: assert t == sorted(t) def test_wheel_full_no_duplicate_tickets(): tickets = wheel_full(list(range(1, 9)), 5) # C(8,5) = 56 as_tuples = [tuple(t) for t in tickets] assert len(as_tuples) == len(set(as_tuples)) def test_wheel_full_all_numbers_in_pool(): pool = [5, 14, 22, 36, 55, 69] tickets = wheel_full(pool, 4) for t in tickets: for n in t: assert n in pool def test_wheel_full_deduplicates_input(): # [1,1,2,3,4,5] → pool [1,2,3,4,5] → C(5,5) = 1 tickets = wheel_full([1, 1, 2, 3, 4, 5], 5) assert len(tickets) == 1 def test_wheel_full_at_cap(monkeypatch): import core.wheeling as wm monkeypatch.setattr(wm, "MAX_TICKETS", 56) # C(8,5) = 56 exactly at cap — should pass tickets = wm.wheel_full(list(range(1, 9)), 5) assert len(tickets) == 56 def test_wheel_full_returns_list_of_lists(): tickets = wheel_full([1, 2, 3, 4, 5, 6], 5) assert isinstance(tickets, list) for t in tickets: assert isinstance(t, list) # ── wheel_full — error cases ────────────────────────────────────────────────── def test_wheel_full_k_zero_raises(): with pytest.raises(ValueError, match="at least 1"): wheel_full([1, 2, 3, 4, 5], 0) def test_wheel_full_k_exceeds_n_raises(): with pytest.raises(ValueError, match="exceeds"): wheel_full([1, 2, 3], 5) def test_wheel_full_exceeds_cap_raises(): # C(10,5) = 252 > MAX_TICKETS (200) with pytest.raises(ValueError, match="252"): wheel_full(list(range(1, 11)), 5) def test_wheel_full_error_message_includes_count(): with pytest.raises(ValueError) as exc_info: wheel_full(list(range(1, 11)), 5) assert "252" in str(exc_info.value) assert str(MAX_TICKETS) in str(exc_info.value)