Add tests for odds util functions
This commit is contained in:
1 parent
ae75f653d7
commit
d8c4a6f34d
1 file changed
+25
@@ -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'
|
||||
Reference in new issue
Block a user