#!/usr/bin/env python3 """No-Limp ist ein Format, kein Detail (lesen/tischregeln.py). `AppStaticConfig.noLimpConfig`: "The first voluntary action into an unopened pot cannot be a limp or call. Players must either open with a pot-sized bet or fold." Das Tischfeld ist `isNoLimp`. An so einem Tisch faellt Limpen und das kleine Open weg: pot-gross oder folden. Die Zeilen unten haben die Form einer Raumzeile des Clients. python3 tests/kein_limp_spec.py -v """ import json import os import sys import unittest HIER = os.path.dirname(os.path.abspath(__file__)) WURZEL = os.path.dirname(HIER) for p in (WURZEL, os.path.join(WURZEL, "lesen")): if p not in sys.path: sys.path.insert(0, p) import tischregeln def zeile(**rp): roh = json.dumps({"roomProperties": rp, "gameType": "Ring"}, separators=(",", ":")) return '[Method] -> SendMessageToPipe - {"BeanData":%s,"Cmd":"game.game_alldata","RoomName":"T"}' \ % json.dumps(roh) NOLIMP = zeile(isNoLimp=True, smallBlind=0.05, bigBlind=0.1) NORMAL = zeile(isNoLimp=False, smallBlind=0.05, bigBlind=0.1) class Startarten(unittest.TestCase): def test_no_limp_tisch_nur_pot_oder_fold(self): self.assertEqual(tischregeln.startarten(NOLIMP), ("POT", "FOLD")) def test_normaler_tisch_laesst_limp_und_klein_zu(self): arten = tischregeln.startarten(NORMAL) self.assertIn("LIMP", arten) self.assertIn("MIN", arten) def test_an_no_limp_ist_limp_verboten(self): self.assertFalse(tischregeln.start_erlaubt(NOLIMP, "LIMP")) self.assertFalse(tischregeln.start_erlaubt(NOLIMP, "MIN")) def test_an_no_limp_ist_pot_erlaubt(self): self.assertTrue(tischregeln.start_erlaubt(NOLIMP, "POT")) self.assertTrue(tischregeln.start_erlaubt(NOLIMP, "FOLD")) def test_kleinschreibung_zaehlt_nicht(self): self.assertTrue(tischregeln.start_erlaubt(NOLIMP, "pot")) def test_ohne_raumzeile_gilt_standard(self): self.assertIn("LIMP", tischregeln.startarten("nichts")) def test_klartext_nennt_das_verbot(self): self.assertIn("pot", tischregeln.klartext(tischregeln.regeln(NOLIMP)).lower()) if __name__ == "__main__": unittest.main()