Skip to content

Harden parsing, fix bugs, and add offline + authenticated tests - #4

Open
dmoraine wants to merge 1 commit into
masterfrom
hardening-and-tests
Open

Harden parsing, fix bugs, and add offline + authenticated tests#4
dmoraine wants to merge 1 commit into
masterfrom
hardening-and-tests

Conversation

@dmoraine

Copy link
Copy Markdown
Owner

Résumé

Passe de maintenance sur le fork : correction de bugs, durcissement du parsing fragile, et surtout une vraie couverture de tests (offline + authentifiée en ligne).

Corrections de bugs

  • Noms de tests dupliqués renommés : plusieurs assertions étaient silencieusement écrasées (Python ne garde que la dernière méthode d'un même nom) et ne s'exécutaient donc jamais.
  • utils.nowtimestamp_millis : renvoie désormais un int de secondes epoch et remplace datetime.utcnow() (déprécié en 3.12) par un now timezone-aware.
  • Dépendance requests inutile retirée (le code n'utilise que curl_cffi).
  • Code mort Python 2 supprimé (unicode / sys.version_info).

Durcissement

  • process_raw_airline_fleet_data : gardes sur l'indexation des cellules, les lignes malformées sont ignorées au lieu de lever IndexError/AttributeError quand flightradar24 modifie son HTML.
  • login : requête et extraction du token encapsulées, retourne un bool.

Tests

  • Suite unitaire offline (test_unit.py, 44 tests, sans réseau) : fltr, helpers de timestamp, byteify/encode, état et parsing de flotte FR24, filtrage de get_flight_for_date, conversion mi→km météo, tous les chemins de login, et le loader de credentials. Devient un vrai gate CI.
  • Suite authentifiée en ligne (test_online_auth.py) : login via FR24_EMAIL/FR24_PASSWORD ou un .env local, et assertion clé — un client connecté voit au moins autant d'historique qu'un anonyme, à budget de pages égal (le seul différenciateur des plans payants). Se skippe proprement sans credentials. Validée en conditions réelles (4 passed).
  • conftest.py : loader/fixture de credentials.
  • pytest.ini : python_files restreint à test_*.py et markers online/auth enregistrés.
  • CI : séparation tests offline (gate strict) / tests réseau (informationnels), avec passage des secrets FR24_* s'ils existent.

🤖 Generated with Claude Code

Bug fixes:
- Rename duplicate test method names that silently shadowed each other,
  so the intended assertions actually run.
- utils.nowtimestamp_millis: return an int of epoch seconds and drop the
  deprecated datetime.utcnow() in favour of a timezone-aware now.
- Remove the unused "requests" dependency (code uses curl_cffi only).
- Drop dead Python 2 code paths (unicode / sys.version_info).

Hardening:
- process_raw_airline_fleet_data: guard cell indexing and skip malformed
  rows instead of raising when flightradar24 tweaks its HTML.
- login: wrap the request and token extraction, and return a bool.

Tests:
- New offline unit suite (test_unit.py) with no network access, covering
  fltr, timestamp helpers, byteify/encode, FR24 state and fleet parsing,
  get_flight_for_date filtering, weather km conversion, login paths, and
  the credential loader. Runs as a real CI gate.
- New authenticated online suite (test_online_auth.py) that logs in with
  credentials from FR24_EMAIL/FR24_PASSWORD or a local .env, and asserts a
  logged-in client sees at least as much history as an anonymous one.
  Skips cleanly when no credentials are configured.
- conftest.py credential loader/fixture.
- pytest.ini: narrow python_files to test_*.py and register markers.
- CI: split offline unit tests (hard gate) from informational network
  tests, and pass FR24 secrets through when present.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant