#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Testlauf ALLE Baende I-VII. Klient: Sibylle Steinmeier. Mail an info@fine-senses.de (BCC via .env)."""
import sys, traceback, time
import worker

EMPF = "info@fine-senses.de"

sibylle = {
    "kunde_name": "Sibylle Steinmeier", "kunde_email": EMPF,
    "geburtsdatum": "11.02.1983", "geburtszeit": "02:20",
    "geburtsort": "Karlsruhe", "geburtsland": "Deutschland",
    "geburt_lat": "49.0069", "geburt_lon": "8.4037",
}
dirk = {
    "name": "Dirk Zessin", "geburtsdatum": "31.03.1976", "geburtszeit": "15:00",
    "geburtsort": "Hamburg", "geburtsland": "Deutschland",
    "geburt_lat": "53.5511", "geburt_lon": "9.9937",
}
patrice = {
    "name": "Patrice Steinmeier", "geburtsdatum": "09.03.2014", "geburtszeit": "22:30",
    "geburtsort": "Hamburg", "geburtsland": "Deutschland",
    "geburt_lat": "53.5511", "geburt_lon": "9.9937",
}

def job_fuer(band):
    j = dict(sibylle)
    j["band"] = band
    if band == "V":
        j["personen_extra"] = [dirk]
    elif band == "VI":
        j["personen_extra"] = [dirk, patrice]
    return j

def lauf(band):
    print("\n" + "="*60); print("TEST Band", band); print("="*60)
    t0 = time.time()
    try:
        res = worker.process_job(job_fuer(band))
        dt = int(time.time() - t0)
        print(">>> OK Band %s (%ds): %s" % (band, dt, res.get("pdf") if isinstance(res, dict) else res))
    except Exception as e:
        print(">>> FEHLER Band %s: %s %s" % (band, type(e).__name__, e))
        traceback.print_exc()

if __name__ == "__main__":
    only = sys.argv[1:] if len(sys.argv) > 1 else ["I","II","III","IV","V","VI","VII"]
    for b in only:
        lauf(b)
    print("\n=== ALLE DURCH ===")
