05/23 Phase 12
This commit is contained in:
@@ -4,6 +4,8 @@ tests/test_dashboard.py
|
||||
Tests for the Dashboard screen data layer and UI smoke tests.
|
||||
"""
|
||||
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
from db.models import (
|
||||
get_all_games, get_game_by_name, get_last_draw,
|
||||
@@ -11,6 +13,7 @@ from db.models import (
|
||||
)
|
||||
from db.database import get_db_stats
|
||||
from core.analyzer import frequency_analysis
|
||||
from ui.dashboard import _next_draw_date
|
||||
|
||||
|
||||
# ── Data-layer checks used by the Dashboard ───────────────────────────────────
|
||||
@@ -77,6 +80,48 @@ def test_predictions_count_correct(tmp_db):
|
||||
assert len(get_predictions(limit=100_000)) == 2
|
||||
|
||||
|
||||
|
||||
# ── _next_draw_date ───────────────────────────────────────────────────────────
|
||||
|
||||
def test_next_draw_powerball_from_friday():
|
||||
# Friday → next Powerball is Saturday
|
||||
fri = date(2024, 5, 24) # Friday, weekday=4
|
||||
result = _next_draw_date("Powerball", from_date=fri)
|
||||
assert "Sat" in result
|
||||
|
||||
|
||||
def test_next_draw_powerball_from_saturday():
|
||||
# Saturday → next Powerball is Monday
|
||||
sat = date(2024, 5, 25) # Saturday, weekday=5
|
||||
result = _next_draw_date("Powerball", from_date=sat)
|
||||
assert "Mon" in result
|
||||
|
||||
|
||||
def test_next_draw_mega_millions_from_friday():
|
||||
# Friday → next MM is Tuesday (4 days away)
|
||||
fri = date(2024, 5, 24)
|
||||
result = _next_draw_date("Mega Millions", from_date=fri)
|
||||
assert "Tue" in result
|
||||
|
||||
|
||||
def test_next_draw_mega_millions_from_monday():
|
||||
# Monday → next MM is Tuesday (1 day away)
|
||||
mon = date(2024, 5, 20) # Monday, weekday=0
|
||||
result = _next_draw_date("Mega Millions", from_date=mon)
|
||||
assert "Tue" in result
|
||||
|
||||
|
||||
def test_next_draw_unknown_game_returns_empty():
|
||||
assert _next_draw_date("Unknown Game") == ""
|
||||
|
||||
|
||||
def test_next_draw_always_in_future():
|
||||
today = date.today()
|
||||
for name in ("Powerball", "Mega Millions"):
|
||||
result = _next_draw_date(name, from_date=today)
|
||||
assert result != "" # always finds a future date within 7 days
|
||||
|
||||
|
||||
# ── UI smoke tests ────────────────────────────────────────────────────────────
|
||||
|
||||
def _has_display():
|
||||
|
||||
Reference in New Issue
Block a user