Files
web-page-backend/lotto/tests/test_backtest.py
2026-05-31 16:49:49 +09:00

26 lines
933 B
Python

from app import backtest as bt
from app.analyzer import build_analysis_cache, score_combination
def test_grade_tickets_histogram_and_prizes():
winning6 = [1, 2, 3, 4, 5, 6]
bonus = 7
tickets = [
[1, 2, 3, 4, 5, 6], # 6일치 = 1등
[1, 2, 3, 4, 5, 7], # 5일치 + 보너스 = 2등
[1, 2, 3, 4, 5, 8], # 5일치 = 3등
[1, 2, 3, 4, 9, 10], # 4일치 = 4등
[1, 2, 3, 11, 12, 13], # 3일치 = 5등
[40, 41, 42, 43, 44, 45], # 0일치
]
r = bt.grade_tickets(tickets, winning6, bonus)
assert r["m6"] == 1
assert r["m5"] == 2 # 5일치 총 2장(보너스 포함)
assert r["bonus_hits"] == 1 # 그 중 보너스 1장
assert r["m4"] == 1
assert r["m3"] == 1
assert r["best_match"] == 6
# 등수 매핑 헬퍼
prizes = bt.prize_counts(r)
assert prizes == {"1st": 1, "2nd": 1, "3rd": 1, "4th": 1, "5th": 1}