Not-Aus heisst keine Eingabe mehr; offene Tische je Raum
Live 30.10.: ESC at 11:03:09 set all stop files, yet the runner clicked "max" and "buyin" at 11:03:12 - stellen_klicken checked only before a sequence, the mouse path never, and cleanup clicked sitout/cross "trotz_stopp". hand/notaus.py is now the one source for the stop files (act, click, stopp); click.click checks before start, on every movement step and before pressing (KlickNotAus), pid_klick too, sequences check before each click, trotz_stopp no longer overrides Not-Aus, dialog.esc sends no key and the live pointer stops. The runner logs "nicht geklickt (Not-Aus)" instead of a sitout it did not do. The header counted every window of a table process (table + dialog = 2); it now counts rooms from the process list. Tests get their own stop folder (POKERFREAK_STOPP_ORDNER) so they never see or touch the machine's Not-Aus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-3
@@ -1163,7 +1163,10 @@ class Sitzer:
|
||||
ereignis("sitout", raum=raum, hinweis="kein Fenster")
|
||||
continue
|
||||
if not lage.sitout() and raum not in self.ausgesetzt:
|
||||
getan += act.stellen_klicken(f, [("sitout", sitzen.SITOUT)], trotz_stopp=True)
|
||||
if not act.stellen_klicken(f, [("sitout", sitzen.SITOUT)], trotz_stopp=True):
|
||||
ereignis("sitout", raum=raum, hinweis="nicht geklickt (Not-Aus)")
|
||||
continue
|
||||
getan.append("sitout")
|
||||
self.ausgesetzt.add(raum)
|
||||
ereignis("sitout", raum=raum, platz=lage.held_sitz)
|
||||
return getan
|
||||
@@ -1194,11 +1197,18 @@ class Sitzer:
|
||||
ereignis("sitout", raum=raum, hinweis="kein Fenster")
|
||||
continue
|
||||
if not lage.sitout() and raum not in self.ausgesetzt:
|
||||
getan += act.stellen_klicken(f, [("sitout", sitzen.SITOUT)], trotz_stopp=True)
|
||||
if not act.stellen_klicken(f, [("sitout", sitzen.SITOUT)], trotz_stopp=True):
|
||||
ereignis("sitout", raum=raum, hinweis="nicht geklickt (Not-Aus)")
|
||||
continue
|
||||
getan.append("sitout")
|
||||
self.ausgesetzt.add(raum)
|
||||
ereignis("sitout", raum=raum, platz=lage.held_sitz)
|
||||
vorher_log = os.path.getsize(LOG) if os.path.exists(LOG) else 0
|
||||
getan += act.stellen_klicken(f, [("kreuz", sitzen.KREUZ)], trotz_stopp=True)
|
||||
kreuz = act.stellen_klicken(f, [("kreuz", sitzen.KREUZ)], trotz_stopp=True)
|
||||
if not kreuz:
|
||||
ereignis("aufraeumen", raum=raum, hinweis="nicht geklickt (Not-Aus)")
|
||||
continue
|
||||
getan += kreuz
|
||||
verlassen_bestaetigen(raum, f, vorher_log, trotz_stopp=True)
|
||||
ereignis("aufgeraeumt", raum=raum, platz=lage.held_sitz,
|
||||
stack=lage.chips.get(lage.held_sitz))
|
||||
|
||||
+8
-4
@@ -25,6 +25,7 @@ import sys
|
||||
import time
|
||||
|
||||
import fenster
|
||||
import notaus
|
||||
import zeiger
|
||||
|
||||
BASE = os.path.dirname(os.path.abspath(__file__))
|
||||
@@ -46,7 +47,8 @@ ZU_TAT = {"FOLD": "fold", "CHECK": "call", "CALL": "call", "RAISE": "raise"}
|
||||
|
||||
|
||||
def gestoppt():
|
||||
return os.path.exists(STOPP)
|
||||
"""Not-Aus gesetzt (hand/notaus.py - alle Stopp-Dateien, wie das Cockpit sie schreibt)."""
|
||||
return notaus.aktiv()
|
||||
|
||||
|
||||
def ziel_fuer(aktion):
|
||||
@@ -125,16 +127,18 @@ FensterNichtVorn = getattr(click, "FensterNichtVorn", ())
|
||||
def stellen_klicken(f, stellen, pause=(0.6, 1.1), rng=None, trotz_stopp=False, wie=None):
|
||||
"""Klickt Stellen (Name, (fx, fy)) als Anteil des Fensterrahmens nacheinander - für das
|
||||
Setzen (hand/sitzen.py). Mit Pause dazwischen, der Dialog braucht kurz. Gibt die Namen
|
||||
zurück, die geklickt wurden. `trotz_stopp`: Sitout und Aufräumen beim Beenden klicken auch
|
||||
bei scratch/stop."""
|
||||
zurück, die geklickt wurden. Not-Aus wird vor jedem Klick gefragt und gilt immer - auch mit
|
||||
`trotz_stopp` (bleibt für die Aufrufer; live 30.10. klickte das Aufräumen nach ESC noch Sitout)."""
|
||||
import random
|
||||
rng = rng or random
|
||||
if (gestoppt() and not trotz_stopp) or not f:
|
||||
if not f:
|
||||
return []
|
||||
geklickt = []
|
||||
for i, (name, (fx, fy)) in enumerate(stellen):
|
||||
if i:
|
||||
time.sleep(rng.uniform(*pause))
|
||||
if gestoppt():
|
||||
break # Not-Aus zwischen zwei Klicks: der Rest fällt weg
|
||||
x, y, w, h = f["rect"]
|
||||
try:
|
||||
_klicken(round(x + w * fx), round(y + h * fy), f, click.maus.halbe_groesse(name, f["rect"]), rng, wie)
|
||||
|
||||
@@ -28,6 +28,7 @@ import sys
|
||||
import time as _time
|
||||
|
||||
import maus
|
||||
import notaus
|
||||
|
||||
FW = "/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices"
|
||||
AS = ctypes.cdll.LoadLibrary(FW)
|
||||
@@ -116,6 +117,15 @@ class FensterNichtVorn(RuntimeError):
|
||||
"""Das Zielfenster kam nicht nach vorn - ein globaler Klick träfe ein fremdes Fenster."""
|
||||
|
||||
|
||||
class KlickNotAus(FensterNichtVorn):
|
||||
"""Not-Aus ist gesetzt - keine Bewegung, kein Druck mehr (hand/notaus.py)."""
|
||||
|
||||
|
||||
def _halt():
|
||||
if notaus.aktiv():
|
||||
raise KlickNotAus("Not-Aus gesetzt - keine Eingabe")
|
||||
|
||||
|
||||
class KlickAusserhalb(FensterNichtVorn):
|
||||
"""Der Klickpunkt liegt nicht im Zielfenster - ein globaler Klick träfe daneben (live 30.10.)."""
|
||||
|
||||
@@ -168,8 +178,10 @@ def _senden_an(pid, art, x, y):
|
||||
def pid_klick(px, py, fenster, halten_s=0.06):
|
||||
"""Klick an den Prozess des Fensters (Bildschirmpunkte) - ohne Maus. -> (px, py)."""
|
||||
pid = fenster["pid"]
|
||||
_halt()
|
||||
_senden_an(pid, MOVED, px, py)
|
||||
_time.sleep(0.02)
|
||||
_halt()
|
||||
_senden_an(pid, DOWN, px, py)
|
||||
_time.sleep(halten_s)
|
||||
_senden_an(pid, UP, px, py)
|
||||
@@ -182,6 +194,7 @@ def click(px, py, pid=None, fenster=None, halb=(0.0, 0.0), rng=random):
|
||||
kurz verweilen, drücken, halten, loslassen. Mit `fenster` (aus hand/fenster.py) ist das
|
||||
Fenster vorn, bevor der Zeiger losgeht und noch einmal unmittelbar vor dem Drücken - sonst
|
||||
FensterNichtVorn und kein Klick."""
|
||||
_halt()
|
||||
weg, verweilen, halten = maus.plan(zeiger(), (px, py), halb, rng)
|
||||
rect = (fenster or {}).get("rect")
|
||||
if rect: # erst schauen, ob er trifft - dann bewegen
|
||||
@@ -196,6 +209,7 @@ def click(px, py, pid=None, fenster=None, halb=(0.0, 0.0), rng=random):
|
||||
warte = beginn + ms / 1000.0 - _time.monotonic()
|
||||
if warte > 0:
|
||||
_time.sleep(warte)
|
||||
_halt() # Not-Aus mitten in der Bewegung: hier bleiben
|
||||
_senden(MOVED, x, y)
|
||||
x, y = weg[-1][1:]
|
||||
_time.sleep(verweilen / 1000.0)
|
||||
@@ -203,6 +217,7 @@ def click(px, py, pid=None, fenster=None, halb=(0.0, 0.0), rng=random):
|
||||
vorne = vorne_pid()
|
||||
if vorne is not None and vorne != pid: # während der Bewegung schob sich etwas davor
|
||||
vorn_sicherstellen(fenster)
|
||||
_halt()
|
||||
_senden(DOWN, x, y)
|
||||
_time.sleep(halten / 1000.0)
|
||||
_senden(UP, x, y)
|
||||
|
||||
+5
-2
@@ -298,8 +298,11 @@ def _eigene_taste():
|
||||
|
||||
|
||||
def esc(f):
|
||||
"""Escape an das Fenster f. True, wenn gesendet."""
|
||||
"""Escape an das Fenster f. True, wenn gesendet - bei Not-Aus nie (hand/notaus.py)."""
|
||||
import fenster
|
||||
import notaus
|
||||
if notaus.aktiv():
|
||||
return False
|
||||
_eigene_taste()
|
||||
if fenster.klon_ohne_mac():
|
||||
import klonmaus
|
||||
@@ -326,7 +329,7 @@ def esc(f):
|
||||
|
||||
|
||||
def kreuz(f, art="profil"):
|
||||
"""Das Kreuz des Dialogs klicken (hand/act.py, auch bei Not-Aus: Aufräumen)."""
|
||||
"""Das Kreuz des Dialogs klicken (hand/act.py - bei Not-Aus nicht, wie jeder Klick)."""
|
||||
import act
|
||||
stelle = DIALOGE[art]["kreuz"]
|
||||
return bool(act.stellen_klicken(f, [(f"kreuz_{art}", stelle)], trotz_stopp=True))
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
"""Not-Aus: ist er gesetzt, geht keine Eingabe mehr raus - keine Mausbewegung, kein Klick, keine Taste.
|
||||
|
||||
Die Dateien schreibt das Cockpit (mac/Sources/CockpitKern/Fenster.swift, mcp/stopp.py); eine
|
||||
genügt. Gefragt wird vor jedem Klick und bei jedem Schritt einer Mausbewegung (hand/click.py) -
|
||||
live 30.10. klickte der Läufer 3 s nach ESC noch "max" und "buyin". Spezifikation: tests/notaus_spec.py.
|
||||
"""
|
||||
import os
|
||||
|
||||
_w = os.path.dirname(os.path.abspath(__file__))
|
||||
while _w != "/" and not os.path.isdir(os.path.join(_w, "hand")):
|
||||
_w = os.path.dirname(_w)
|
||||
WURZEL = _w
|
||||
|
||||
# POKERFREAK_STOPP_ORDNER: eigener Ordner (tests/lauf.py) - Tests sehen den Not-Aus dieses Rechners
|
||||
# nicht und setzen oder löschen ihn nie.
|
||||
_ORDNER = os.environ.get("POKERFREAK_STOPP_ORDNER")
|
||||
PFADE = [os.path.join(_ORDNER, "stop")] if _ORDNER else [
|
||||
os.path.join(WURZEL, "scratch", "stop"),
|
||||
os.path.join(WURZEL, "hand", "scratch", "stop"),
|
||||
os.path.join(WURZEL, "betrieb", "scratch", "stop"),
|
||||
]
|
||||
|
||||
|
||||
def aktiv():
|
||||
"""Ist der Not-Aus gesetzt (irgendeine der Dateien da)?"""
|
||||
return any(os.path.exists(p) for p in PFADE)
|
||||
+5
-1
@@ -28,6 +28,7 @@ import math
|
||||
import random
|
||||
|
||||
import maus
|
||||
import notaus
|
||||
|
||||
PROFIL = {
|
||||
"schritt_ms": maus.SCHRITT_MS, # Abtastung der Fahrten
|
||||
@@ -654,6 +655,9 @@ class Lauf:
|
||||
def _laufen(self):
|
||||
gesehen_zuletzt = gemieden_zuletzt = 0.0
|
||||
while not self.halt.is_set():
|
||||
if notaus.aktiv(): # Not-Aus: keine Bewegung, auch nicht im Leerlauf
|
||||
self.halt.wait(TAKT_S)
|
||||
continue
|
||||
jetzt = time.monotonic()
|
||||
gesehen = None
|
||||
if self.meiden and jetzt - gemieden_zuletzt >= MEIDEN_TAKT_S:
|
||||
@@ -674,7 +678,7 @@ class Lauf:
|
||||
with self.sperre:
|
||||
punkte = schritt(self.z, jetzt, self.rng, gesehen)
|
||||
for x, y in punkte: # alle fälligen: so springt er auch nach Stau nicht
|
||||
if self.z["modus"] == "ruhe_klick":
|
||||
if self.z["modus"] == "ruhe_klick" or notaus.aktiv():
|
||||
break
|
||||
try:
|
||||
self.bewegen(x, y)
|
||||
|
||||
+5
-5
@@ -10,11 +10,11 @@ while _w != "/" and not os.path.isdir(os.path.join(_w, "hand")):
|
||||
_w = os.path.dirname(_w)
|
||||
WURZEL = _w
|
||||
|
||||
STOPP_PFADE = [
|
||||
os.path.join(WURZEL, "scratch", "stop"),
|
||||
os.path.join(WURZEL, "hand", "scratch", "stop"),
|
||||
os.path.join(WURZEL, "betrieb", "scratch", "stop"),
|
||||
]
|
||||
import sys
|
||||
sys.path.insert(0, os.path.join(WURZEL, "hand"))
|
||||
import notaus # noqa: E402 eine Quelle für die Stopp-Dateien
|
||||
|
||||
STOPP_PFADE = notaus.PFADE
|
||||
|
||||
|
||||
def ist_gestoppt():
|
||||
|
||||
@@ -488,6 +488,8 @@ def kopf(q, jetzt, lagen=None, jz=None):
|
||||
text = "läuft nichts" + (f" - zuletzt gesehen {_uhr(zuletzt)}" if zuletzt else " - noch nie gesehen")
|
||||
fenster = q.get("fenster")
|
||||
offen_n = len(fenster) if isinstance(fenster, list) else None # offene Tischfenster (auch ohne Sitz)
|
||||
if isinstance(q.get("tisch_raeume"), list): # je Raum einmal: ein Tisch mit Dialog sind zwei Fenster (30.10.)
|
||||
offen_n = len(set(q["tisch_raeume"]))
|
||||
tische_text = (f"{offen_n} offen, {len(tische)} sitzend" if offen_n is not None
|
||||
else (f"{len(tische)} sitzend" if tische else "keine bekannt"))
|
||||
not_aus = bool(q.get("gestoppt"))
|
||||
|
||||
@@ -34,6 +34,9 @@ class ImFenster(unittest.TestCase):
|
||||
click.vorn_sicherstellen = lambda f: None
|
||||
click.zeiger = lambda: (0.0, 0.0)
|
||||
click.vorne_pid = lambda: 42
|
||||
alt = click.notaus.aktiv # unabhängig vom Not-Aus dieses Rechners
|
||||
click.notaus.aktiv = lambda: False
|
||||
self.addCleanup(setattr, click.notaus, "aktiv", alt)
|
||||
click._time.sleep = lambda s: None
|
||||
self.ende = None
|
||||
click.maus.plan = lambda start, ziel, halb, rng: ([(0, 50.0, 50.0), (10,) + (self.ende or ziel)], 0, 0)
|
||||
|
||||
+3
-1
@@ -15,6 +15,7 @@ import concurrent.futures
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import sys
|
||||
import time
|
||||
|
||||
@@ -42,7 +43,8 @@ SPERRPORT = "1"
|
||||
|
||||
|
||||
def umgebung():
|
||||
return dict(os.environ, CDP_PORT=SPERRPORT)
|
||||
"""Ohne echten Client (CDP_PORT) und mit eigenem Not-Aus-Ordner (hand/notaus.py)."""
|
||||
return dict(os.environ, CDP_PORT=SPERRPORT, POKERFREAK_STOPP_ORDNER=tempfile.mkdtemp(prefix="pf-stopp-"))
|
||||
|
||||
|
||||
def _lauf(name):
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Not-Aus heisst: keine Eingabe mehr - keine Mausbewegung, kein Klick, keine Taste (hand/notaus.py).
|
||||
|
||||
Live 30.10. 11:03:09 ESC (Not-Aus, beide Dateien gesetzt), 11:03:12 klickte der Läufer noch
|
||||
"max" und "buyin": stellen_klicken prüfte nur vor der Folge, die Mausbewegung gar nicht, und
|
||||
beim Beenden klickte er Sitout und Kreuz ausdrücklich "trotz_stopp".
|
||||
|
||||
* hand/notaus.aktiv(): eine der Stopp-Dateien (scratch/, hand/scratch/, betrieb/scratch/) da.
|
||||
* click.click: vor dem Start, bei jedem Schritt der Bewegung und vor dem Drücken - ist Not-Aus
|
||||
aktiv, geht nichts mehr raus (KlickNotAus, ein FensterNichtVorn). pid_klick ebenso.
|
||||
* act.stellen_klicken: vor jedem Klick der Folge; `trotz_stopp` gilt bei Not-Aus nicht.
|
||||
* dialog.esc: keine Taste bei Not-Aus.
|
||||
* Der lebende Zeiger (hand/zeiger.Lauf) bewegt bei Not-Aus nichts - auch nicht, wenn er schon lief.
|
||||
|
||||
python3 tests/notaus_spec.py -v
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
_w = os.path.dirname(os.path.abspath(__file__))
|
||||
while _w != "/" and not os.path.isdir(os.path.join(_w, "hand")):
|
||||
_w = os.path.dirname(_w)
|
||||
for _u in ("hand", "lesen", "mcp"):
|
||||
sys.path.insert(0, os.path.join(_w, _u))
|
||||
|
||||
import act
|
||||
import click
|
||||
import dialog
|
||||
import notaus
|
||||
import stopp
|
||||
|
||||
FENSTER = {"pid": 42, "rect": (100, 100, 800, 600)}
|
||||
|
||||
|
||||
class Dateien(unittest.TestCase):
|
||||
def test_eine_datei_genuegt(self):
|
||||
ordner = tempfile.mkdtemp()
|
||||
alt = notaus.PFADE
|
||||
notaus.PFADE = [os.path.join(ordner, n) for n in ("a", "b")]
|
||||
try:
|
||||
self.assertFalse(notaus.aktiv())
|
||||
open(notaus.PFADE[1], "w").close()
|
||||
self.assertTrue(notaus.aktiv())
|
||||
finally:
|
||||
notaus.PFADE = alt
|
||||
|
||||
def test_dieselben_dateien_wie_das_cockpit(self):
|
||||
self.assertEqual(sorted(stopp.STOPP_PFADE), sorted(notaus.PFADE))
|
||||
if not os.environ.get("POKERFREAK_STOPP_ORDNER"): # ohne Test-Ordner: die der App
|
||||
self.assertEqual(sorted(p.replace(notaus.WURZEL + "/", "") for p in notaus.PFADE),
|
||||
["betrieb/scratch/stop", "hand/scratch/stop", "scratch/stop"])
|
||||
|
||||
|
||||
class Schalter:
|
||||
"""notaus.aktiv() schaltet nach `nach` Abfragen auf an."""
|
||||
|
||||
def __init__(self, nach):
|
||||
self.n, self.nach = 0, nach
|
||||
|
||||
def __call__(self):
|
||||
self.n += 1
|
||||
return self.n > self.nach
|
||||
|
||||
|
||||
class Klick(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.alt = (click._senden, click._senden_an, click.vorn_sicherstellen, click.zeiger, click.vorne_pid,
|
||||
click._time.sleep, click.maus.plan, notaus.aktiv)
|
||||
self.gesendet = []
|
||||
click._senden = lambda art, x, y: self.gesendet.append((art, x, y))
|
||||
click._senden_an = lambda pid, art, x, y: self.gesendet.append((art, x, y))
|
||||
click.vorn_sicherstellen = lambda f: None
|
||||
click.zeiger = lambda: (0.0, 0.0)
|
||||
click.vorne_pid = lambda: 42
|
||||
click._time.sleep = lambda s: None
|
||||
click.maus.plan = lambda start, ziel, halb, rng: ([(i, 200.0 + i, 200.0) for i in range(10)] + [(10,) + ziel], 0, 0)
|
||||
|
||||
def tearDown(self):
|
||||
(click._senden, click._senden_an, click.vorn_sicherstellen, click.zeiger, click.vorne_pid,
|
||||
click._time.sleep, click.maus.plan, notaus.aktiv) = self.alt
|
||||
|
||||
def test_vorher_aktiv_nichts(self):
|
||||
notaus.aktiv = lambda: True
|
||||
with self.assertRaises(click.KlickNotAus):
|
||||
click.click(500, 400, fenster=FENSTER)
|
||||
self.assertEqual(self.gesendet, [])
|
||||
|
||||
def test_mitten_in_der_bewegung_kein_druck(self):
|
||||
notaus.aktiv = Schalter(nach=4)
|
||||
with self.assertRaises(click.KlickNotAus):
|
||||
click.click(500, 400, fenster=FENSTER)
|
||||
self.assertNotIn(click.DOWN, [a for a, _, _ in self.gesendet])
|
||||
self.assertLess(len(self.gesendet), 11) # die Bewegung hielt an
|
||||
|
||||
def test_vor_dem_druecken(self):
|
||||
notaus.aktiv = Schalter(nach=12) # Start + 11 Schritte frei, dann an
|
||||
with self.assertRaises(click.KlickNotAus):
|
||||
click.click(500, 400, fenster=FENSTER)
|
||||
self.assertNotIn(click.DOWN, [a for a, _, _ in self.gesendet])
|
||||
|
||||
def test_ohne_not_aus_klickt_er(self):
|
||||
notaus.aktiv = lambda: False
|
||||
click.click(500, 400, fenster=FENSTER)
|
||||
self.assertIn((click.DOWN, 500, 400), self.gesendet)
|
||||
|
||||
def test_ohne_maus_ebenso(self):
|
||||
notaus.aktiv = lambda: True
|
||||
with self.assertRaises(click.KlickNotAus):
|
||||
click.pid_klick(500, 400, FENSTER)
|
||||
self.assertEqual(self.gesendet, [])
|
||||
|
||||
def test_wird_wie_ein_verweigerter_klick_gefangen(self):
|
||||
self.assertTrue(issubclass(click.KlickNotAus, click.FensterNichtVorn))
|
||||
|
||||
|
||||
class Folge(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.alt = (act._klicken, notaus.aktiv)
|
||||
self.geklickt = []
|
||||
act._klicken = lambda px, py, f, halb, rng=None, wie=None: self.geklickt.append((px, py))
|
||||
|
||||
def tearDown(self):
|
||||
act._klicken, notaus.aktiv = self.alt
|
||||
|
||||
def test_not_aus_zwischen_max_und_buyin(self):
|
||||
stand = {"aus": False}
|
||||
notaus.aktiv = lambda: stand["aus"]
|
||||
act._klicken = lambda px, py, f, halb, rng=None, wie=None: (self.geklickt.append((px, py)),
|
||||
stand.update(aus=True))
|
||||
g = act.stellen_klicken(FENSTER, [("max", (0.5, 0.5)), ("buyin", (0.6, 0.6))], pause=(0, 0))
|
||||
self.assertEqual(g, ["max"])
|
||||
self.assertEqual(len(self.geklickt), 1)
|
||||
|
||||
def test_trotz_stopp_gilt_bei_not_aus_nicht(self):
|
||||
notaus.aktiv = lambda: True
|
||||
self.assertEqual(act.stellen_klicken(FENSTER, [("sitout", (0.1, 0.1))], trotz_stopp=True), [])
|
||||
self.assertEqual(self.geklickt, [])
|
||||
|
||||
def test_gestoppt_ist_not_aus(self):
|
||||
notaus.aktiv = lambda: True
|
||||
self.assertTrue(act.gestoppt())
|
||||
|
||||
|
||||
class Taste(unittest.TestCase):
|
||||
def test_kein_esc_bei_not_aus(self):
|
||||
alt = notaus.aktiv
|
||||
notaus.aktiv = lambda: True
|
||||
try:
|
||||
self.assertFalse(dialog.esc({"pid": 42, "rect": (0, 0, 10, 10)}))
|
||||
finally:
|
||||
notaus.aktiv = alt
|
||||
|
||||
|
||||
class LebenderZeiger(unittest.TestCase):
|
||||
def setUp(self):
|
||||
import random
|
||||
import time
|
||||
import zeiger
|
||||
self.time, self.zeiger = time, zeiger
|
||||
self.alt = notaus.aktiv
|
||||
self.aus = {"an": False}
|
||||
notaus.aktiv = lambda: self.aus["an"]
|
||||
self.gesendet = []
|
||||
kasten = os.path.join(tempfile.mkdtemp(), "auftraege.jsonl")
|
||||
self.lauf = zeiger.Lauf(lambda x, y: self.gesendet.append((x, y)),
|
||||
lambda: self.gesendet[-1] if self.gesendet else (600.0, 400.0),
|
||||
(0.0, 0.0, 1200.0, 860.0), rng=random.Random(1), briefkasten=kasten)
|
||||
|
||||
def tearDown(self):
|
||||
self.lauf.stoppen()
|
||||
notaus.aktiv = self.alt
|
||||
|
||||
def test_bei_not_aus_keine_bewegung(self):
|
||||
self.aus["an"] = True
|
||||
self.lauf.starten()
|
||||
self.time.sleep(3.0)
|
||||
self.assertEqual(self.gesendet, [])
|
||||
|
||||
def test_not_aus_haelt_den_laufenden_zeiger_an(self):
|
||||
self.lauf.starten()
|
||||
self.time.sleep(3.0)
|
||||
self.assertTrue(self.gesendet, "der Zeiger lebt nicht")
|
||||
self.aus["an"] = True
|
||||
self.time.sleep(0.2)
|
||||
n = len(self.gesendet)
|
||||
self.time.sleep(1.5)
|
||||
self.assertEqual(len(self.gesendet), n)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -604,6 +604,22 @@ class JetztNurMitTisch(unittest.TestCase):
|
||||
self.assertEqual([z["raum"] for z in a["entscheidungen"]["zeilen"]], ["Big Ben 1"])
|
||||
|
||||
|
||||
class OffeneTischeJeRaum(unittest.TestCase):
|
||||
"""Live 30.10. 11:03: ein Tisch offen, das Cockpit zeigte zwei - jedes Fenster eines
|
||||
Tischprozesses zählte (Tisch und Dialog). Gezählt werden Räume aus der Prozessliste."""
|
||||
|
||||
def test_zwei_fenster_ein_tisch(self):
|
||||
f = [{"titel": "NLH 1676424 - 1K/2K", "tisch": "1676424", "raum": "Big Ben 1676424"},
|
||||
{"titel": "Buy-in", "tisch": None, "raum": None}]
|
||||
k = ansicht.bauen(quelle(client=True, tisch_raeume=["Big Ben 1676424"], fenster=f), JETZT)["kopf"]
|
||||
self.assertEqual(k["tische_offen"], 1)
|
||||
self.assertTrue(k["tische_text"].startswith("1 offen"))
|
||||
|
||||
def test_ohne_prozessliste_wie_bisher(self):
|
||||
f = [{"titel": "a", "tisch": "1", "raum": "A"}, {"titel": "b", "tisch": "2", "raum": "B"}]
|
||||
self.assertEqual(ansicht.bauen(quelle(tisch_raeume=None, fenster=f), JETZT)["kopf"]["tische_offen"], 2)
|
||||
|
||||
|
||||
class LaeuferTot(unittest.TestCase):
|
||||
"""Live 29.10. 23:14: der Läufer hatte sich um 23:01 selbst abgebrochen ("abbruch", "beendet",
|
||||
kein "ende") - das Cockpit hielt ihn für laufend, "Aufhören" lief ins Leere."""
|
||||
|
||||
@@ -324,6 +324,9 @@ class LaufImFaden(unittest.TestCase):
|
||||
self.tmp = tempfile.mkdtemp()
|
||||
self.kasten = os.path.join(self.tmp, "auftraege.jsonl")
|
||||
self.gesendet = []
|
||||
alt = zeiger.notaus.aktiv # unabhängig vom Not-Aus dieses Rechners
|
||||
zeiger.notaus.aktiv = lambda: False
|
||||
self.addCleanup(setattr, zeiger.notaus, "aktiv", alt)
|
||||
self.lauf = zeiger.Lauf(lambda x, y: self.gesendet.append((time.monotonic(), x, y)),
|
||||
lambda: self.gesendet[-1][1:] if self.gesendet else (600.0, 400.0),
|
||||
GRENZEN, stellen={"fold": (0.5, 0.9)}, rng=random.Random(1),
|
||||
|
||||
Reference in New Issue
Block a user