From 9992abb8a2852d26ff46f9c4d99a81bf0f238fcb Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 2 Mar 2026 19:09:33 -0500 Subject: [PATCH] Remove extra unused code, test new powerball object function --- tests/test_util.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/test_util.py b/tests/test_util.py index 4057cde..8c2541a 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,12 +1,13 @@ """Tests for the `util` module.""" +from datetime import datetime from dotenv import load_dotenv -import os import pytest import util.convert as uc import util.drawing as ud import util.scrape as sc import util.odds as uo +from data.database import PowerballDraw load_dotenv() @@ -15,7 +16,7 @@ def test_convert_string_to_integer() -> None: """Test string value conversion to integer.""" assert uc.convert_string_to_integer("0") == 0 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") @@ -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="powerball") assert not ud.get_next_draw_date(game="something") - with pytest.raises(TypeError) as exc: + with pytest.raises(TypeError): ud.get_next_draw_date() @@ -61,12 +62,12 @@ def test_scrape_game_history(game) -> 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=18, draw_count=1) == 18 with pytest.raises(TypeError): uo.calculate_odds() - with pytest.raises(ValueError) as exc: + with pytest.raises(ValueError): 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( 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: + with pytest.raises(TypeError): uo.get_odds_of_winning() - with pytest.raises(ValueError) as exc: + with pytest.raises(ValueError): 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' + + +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