Wire the web-scraper as a third update fallback, add regression tests

AutoUpdateAndLearn.update_data() now falls back to LottoWebUpdater
(lotto.de scraping) when the API chain (Lottoland/GitHub/lottoAPI)
returns no new data, matching the pattern already in production on
the Eurojackpot sibling project. Required installing beautifulsoup4
into the venv - its absence would have crashed the entire update
script the moment the fallback import was added, not just the
fallback path itself, so this needed verifying before wiring it in.

Also adds tests/test_popularity_score.py (pytest): regression coverage
for the popularity/EV score against known overplayed combinations
(1-2-3-4-5-6, 5-10-15-20-25-30) and the Superzahl EV ordering. Verified
against the pre-fix code (commit 8c2089d) that these tests would
actually have caught the sum-extremity bug fixed in e05f1f1 - this
had previously only been caught by manual spot-checking.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
cbazzaandClaude Sonnet 5 committed 2026-09-12 10:08:45 +02:00
1 parent 73a6b43ec9
commit ec7290ece5
4 files changed
+135 -14

No files matched your search

+18 -9
View File
@@ -39,7 +39,7 @@ Lotto/
│ └── utils/
│ ├── notifier.py # Telegram/Email
│ ├── update_from_api.py # API-Updater (aktiv)
│ ├── update_from_web.py # Web-Scraping-Fallback (nicht automatisiert)
│ ├── update_from_web.py # Web-Scraping-Fallback (automatisch, wenn API nichts liefert)
│ ├── simple_update.py # Manuelle Eingabe
│ ├── watchdog.py # Prüft Daten-/Modell-Aktualität, alarmiert per Telegram
│ ├── validate_csv.py # manuelles Utility
@@ -61,7 +61,7 @@ Lotto/
```bash
python3 -m venv venv
source venv/bin/activate
pip install pandas numpy scikit-learn requests torch
pip install pandas numpy scikit-learn requests torch beautifulsoup4
```
### 2. Telegram-Bot einrichten
@@ -121,15 +121,15 @@ höhere Auszahlung. Details und Quellen dazu in
## 🔄 Daten aktualisieren
Der automatisierte Workflow (`auto_update_and_learn.py`) nutzt
`LottoAPIUpdater.fetch_from_all_apis()`: Lottoland zuerst (liefert die
neueste Ziehung meist noch am Ziehungstag), GitHub-Archiv für die Historie.
Für manuelle Läufe stehen zusätzlich bereit:
Der automatisierte Workflow (`auto_update_and_learn.py`) versucht in dieser
Reihenfolge: **1.** `LottoAPIUpdater.fetch_from_all_apis()` (Lottoland zuerst,
liefert die neueste Ziehung meist noch am Ziehungstag, dann GitHub-Archiv für
die Historie), **2.** bei leerem API-Ergebnis automatisch der Web-Scraper
(`update_from_web.py`, lotto.de) als Fallback.
Für manuelle Läufe steht zusätzlich bereit:
```bash
# Web-Scraping-Fallback (lotto.de) - nicht in der Automatisierung verdrahtet
python scripts/utils/update_from_web.py
# Letzter Fallback: manuelle Eingabe / CSV-Import
python scripts/utils/simple_update.py
```
@@ -168,6 +168,15 @@ für Alarme.
Alle Generierungen werden in `data/generated_tips/generation_history.json`
protokolliert, alle Ziehungsauswertungen in `data/learning_log.json`.
## 🧪 Tests
Regressionstests für den Popularity/EV-Score (`tests/test_popularity_score.py`):
```bash
pip install pytest
pytest tests/
```
## 🗂️ Datenformat
`data/AlleLottozahlen.csv` (Semikolon-getrennt):