From d8c4a6f34d21b7aa3dc81f22291f0164348e705c Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 25 Feb 2026 14:10:15 -0500 Subject: [PATCH] Add tests for odds util functions --- tests/test_util.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_util.py b/tests/test_util.py index 8b5135a..29b2909 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -6,6 +6,7 @@ import pytest import util.convert as uc import util.drawing as ud import util.scrape as sc +import util.odds as uo load_dotenv() @@ -51,3 +52,27 @@ def test_scrape_game_history(game) -> None: """Test scraping the powerball result page for 1996.""" scrape_data = sc.scrape_game_history(game, year=1996) assert len(scrape_data) in [17, 104] + + +def test_calculate_odds() -> None: + """The the odds calculation for a number of draws within a specific pool size""" + assert uo.calculate_odds(pool_size=49, draw_count=5) == 1906884 + assert uo.calculate_odds(pool_size=18, draw_count=1) == 18 + with pytest.raises(TypeError): + uo.calculate_odds() + with pytest.raises(ValueError) as exc: + uo.calculate_odds(pool_size=1, draw_count=2) + + +def test_get_odds_of_winning() -> None: + assert uo.get_odds_of_winning( + main_ball_draw_pool=49, main_ball_draw_count=5, game_ball_draw_pool=18, game_ball_draw_count=1 + ) == 'The odds of winning are 1 in 34,323,912' + with pytest.raises(TypeError) as exc: + uo.get_odds_of_winning() + with pytest.raises(ValueError) as exc: + uo.get_odds_of_winning( + main_ball_draw_pool=49, main_ball_draw_count= 50, game_ball_draw_pool=18, game_ball_draw_count=1) + assert uo.get_odds_of_winning( + main_ball_draw_pool=69, main_ball_draw_count=5, game_ball_draw_pool=26, game_ball_draw_count=1 + ) == 'The odds of winning are 1 in 292,201,338'