Files
pokerfreak/tests/lobby_klick_spec.py
mmintel 9c79d8236b Acceptance 5.11.: channel play without AFK, quiet focus, working Cockpit, stronger play
- Practice tables: 20-min session 54/54 turns at the server, control session 28 turns,
  0 timeouts; stage: 3 tables, two rounds each, clean teardown.
- Never let the clock run: an engine abstention becomes check or fold (nie_verstreichen).
- Mittler join in a fixed order (kill the duplicate, then announce), a mittler ends with its
  game, the laufwache opens no tables, stop waits for the runner to stand up.
- Focus: no lobby connections from HUD, probes or layout; "Focus Window on Turn" off.
- Tables: disconnected or sitting-out opponents do not count; a table without channel is
  closed and avoided after 45 s; the join event keeps the writer's pid (strict invariants).
- Geldwache: same room list as the runner, the table's own report, stand up before closing.
- Engine: the small blind completes the top 65 % against limpers (price per fair share);
  the calling range of a bet is as wide as the villain calls - value bets into stations.
- Cockpit: the source tree never comes from SHELL; one operating set for laufwache and
  Cockpit (sicht/start.py --client, ServerStart).
- Project lives in ~/Projects/pokerfreak (kern was a detour).
2026-11-05 16:10:43 +01:00

80 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Der Lobby-Klick (mcp/lobby_adapter._klick_echt) gehorcht der Maus-Regel.
Anlass (5.11.): der Rueckfall des Beitritts schickte ECHTE Mausereignisse (CGEventPost) an den
Bildschirm - ohne den Schalter `umgebung.maus()` zu fragen. Lag die Lobby nicht vorn, traf der
Klick ein beliebiges anderes Fenster. Der Beitritt hat einen Kanalweg (hand/beitritt.py); ohne
eingeschaltete Maus bleibt dieser Rueckfall zu.
python3 tests/lobby_klick_spec.py -v
"""
import ctypes
import os
import sys
import tempfile
import unittest
from unittest.mock import patch
_w = os.path.dirname(os.path.abspath(__file__))
while _w != "/" and not os.path.isdir(os.path.join(_w, "mcp")):
_w = os.path.dirname(_w)
for _u in ("lesen", "lobby", "client", "hand", "mcp"):
sys.path.insert(0, os.path.join(_w, _u))
import lobby_adapter # noqa: E402
import umgebung # noqa: E402
class Ersatzbibliothek:
"""Statt ApplicationServices: schreibt mit, was gepostet wuerde - kein Ereignis geht raus."""
class _Erzeugen:
restype = None
argtypes = None
def __call__(self, *a):
return 1
def __init__(self):
self.gepostet = []
self.CGEventCreateMouseEvent = self._Erzeugen()
def CGEventPost(self, *a):
self.gepostet.append(a)
class MausRegel(unittest.TestCase):
def setUp(self):
self.ord = tempfile.TemporaryDirectory()
self.alt_flag = umgebung.MAUS_FLAG
umgebung.MAUS_FLAG = os.path.join(self.ord.name, "maus") # Schalter aus: Datei fehlt
self.alt_env = os.environ.pop("COINPOKER_MAUS", None)
self.bib = Ersatzbibliothek()
self.flicken = [patch.object(lobby_adapter, "cdp_ausfuehren", return_value='{"x": 10, "y": 20}'),
patch.object(lobby_adapter, "_fenster_versatz", return_value=(0, 0)),
patch.object(ctypes, "CDLL", return_value=self.bib)]
for f in self.flicken:
f.start()
def tearDown(self):
for f in self.flicken:
f.stop()
umgebung.MAUS_FLAG = self.alt_flag
os.environ.pop("COINPOKER_MAUS", None)
if self.alt_env is not None:
os.environ["COINPOKER_MAUS"] = self.alt_env
self.ord.cleanup()
def test_ohne_maus_kein_echtes_ereignis(self):
self.assertFalse(lobby_adapter._klick_echt("document.body", "Join"))
self.assertEqual(self.bib.gepostet, [])
def test_mit_maus_hin_druecken_loslassen(self):
os.environ["COINPOKER_MAUS"] = "1"
self.assertTrue(lobby_adapter._klick_echt("document.body", "Join"))
self.assertEqual(len(self.bib.gepostet), 3)
if __name__ == "__main__":
unittest.main(verbosity=2)