Skip to content

collmex buchen --dry-run sollte keine Collmex-Credentials brauchen #4

Description

@atraining

Problem

Aktuell instanziiert die CLI in den buchen/ausgang/storno-Kommandos einen CollmexClient bevor auf --dry-run verzweigt wird. CollmexClient.__init__ (collmex/api.py:194) ruft load_dotenv() auf und validiert die vier Pflicht-Env-Variablen — sonst CollmexError("COLLMEX_URL nicht konfiguriert").

Folge: Dry-Run funktioniert nur, wenn eine gültige .env vorhanden ist, obwohl gar kein API-Call stattfindet.

Symptom

In CI sind die Dry-Run-Tests nur deshalb grün, weil tests/conftest.py::_fake_collmex_env per monkeypatch.setenv Dummy-Werte injiziert (Fix in 3b2346f). Das ist ein Workaround, kein sauberes Design.

Vorschlag

Client lazy erzeugen:

  1. Dry-Run-Branch zuerst prüfen, Booking rein lokal bauen und ausgeben.
  2. CollmexClient() nur im Nicht-Dry-Run-Pfad instanziieren.
  3. Alternativ: CollmexClient.__init__ macht nur load_dotenv, Validierung wandert in eine separate Methode _validate_credentials() oder in die erste echte Request-Methode.

Gewinn

  • Dry-Run funktioniert ohne Credentials (sinnvoll für Evaluation/Demos).
  • Autouse-Fixture in conftest.py kann wieder weg oder reduziert werden.
  • Besseres Separation-of-Concerns.

Betroffene Stellen

  • collmex/cli.py (Kommandos buchen, ausgang, storno)
  • collmex/api.py:194-220
  • tests/conftest.py::_fake_collmex_env

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions