Remove extra unused code, test new powerball object function
This commit is contained in:
1 parent
b8ce4ac078
commit
9992abb8a2
1 file changed
+16
-7
+16
-7
@@ -1,12 +1,13 @@
|
|||||||
"""Tests for the `util` module."""
|
"""Tests for the `util` module."""
|
||||||
|
from datetime import datetime
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import util.convert as uc
|
import util.convert as uc
|
||||||
import util.drawing as ud
|
import util.drawing as ud
|
||||||
import util.scrape as sc
|
import util.scrape as sc
|
||||||
import util.odds as uo
|
import util.odds as uo
|
||||||
|
from data.database import PowerballDraw
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ def test_convert_string_to_integer() -> None:
|
|||||||
"""Test string value conversion to integer."""
|
"""Test string value conversion to integer."""
|
||||||
assert uc.convert_string_to_integer("0") == 0
|
assert uc.convert_string_to_integer("0") == 0
|
||||||
assert uc.convert_string_to_integer("3.14") == 3
|
assert uc.convert_string_to_integer("3.14") == 3
|
||||||
with pytest.raises(uc.InvalidStringException) as exc:
|
with pytest.raises(uc.InvalidStringException):
|
||||||
uc.convert_string_to_integer("a")
|
uc.convert_string_to_integer("a")
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ def test_get_next_draw_date_minimum() -> None:
|
|||||||
assert ud.get_next_draw_date(game="mega-millions")
|
assert ud.get_next_draw_date(game="mega-millions")
|
||||||
assert ud.get_next_draw_date(game="powerball")
|
assert ud.get_next_draw_date(game="powerball")
|
||||||
assert not ud.get_next_draw_date(game="something")
|
assert not ud.get_next_draw_date(game="something")
|
||||||
with pytest.raises(TypeError) as exc:
|
with pytest.raises(TypeError):
|
||||||
ud.get_next_draw_date()
|
ud.get_next_draw_date()
|
||||||
|
|
||||||
|
|
||||||
@@ -61,12 +62,12 @@ def test_scrape_game_history(game) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_calculate_odds() -> None:
|
def test_calculate_odds() -> None:
|
||||||
"""The the odds calculation for a number of draws within a specific pool size"""
|
"""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=49, draw_count=5) == 1906884
|
||||||
assert uo.calculate_odds(pool_size=18, draw_count=1) == 18
|
assert uo.calculate_odds(pool_size=18, draw_count=1) == 18
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
uo.calculate_odds()
|
uo.calculate_odds()
|
||||||
with pytest.raises(ValueError) as exc:
|
with pytest.raises(ValueError):
|
||||||
uo.calculate_odds(pool_size=1, draw_count=2)
|
uo.calculate_odds(pool_size=1, draw_count=2)
|
||||||
|
|
||||||
|
|
||||||
@@ -74,11 +75,19 @@ def test_get_odds_of_winning() -> None:
|
|||||||
assert uo.get_odds_of_winning(
|
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
|
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'
|
) == 'The odds of winning are 1 in 34,323,912'
|
||||||
with pytest.raises(TypeError) as exc:
|
with pytest.raises(TypeError):
|
||||||
uo.get_odds_of_winning()
|
uo.get_odds_of_winning()
|
||||||
with pytest.raises(ValueError) as exc:
|
with pytest.raises(ValueError):
|
||||||
uo.get_odds_of_winning(
|
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)
|
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(
|
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
|
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'
|
) == 'The odds of winning are 1 in 292,201,338'
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_powerball_object() -> None:
|
||||||
|
data_value = ud.get_powerball_object(draw_date='2026-01-03', draw_result={'main_balls': [18, 21, 40, 53, 60],
|
||||||
|
'powerball': 23, 'multiplier': 3})
|
||||||
|
test_record = PowerballDraw(draw_date=datetime(2026, 1, 3).date(), main_ball1=18, main_ball2=21,
|
||||||
|
main_ball3=40, main_ball4=53, main_ball5=60, powerball=23, power_play=3)
|
||||||
|
assert data_value == test_record
|
||||||
Reference in new issue
Block a user