# Spezifikation der reinen Teile von farm_basisplus. python3 tests/farm_basisplus_spec.py import sys; sys.dont_write_bytecode = True import os, unittest sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "messung", "farm", "nacht-0112", "werkzeuge")) import farm_basisplus as B # noqa: E402 class Marken(unittest.TestCase): def test_klammern_nl2_und_motorweg(self): self.assertEqual(B.marken("motor TURN genau (90 ms) [Stapel-Preis@0.5 eq] [GPU aus: Frist]"), ["Stapel-Preis", "GPU"]) self.assertEqual(B.marken("NL2-Typ: Fisch callt zu weit, Bet 0.75"), ["NL2-Typ"]) self.assertEqual(B.marken("motor RIVER genau (302 ms, Topf 650 Rest 7800): Check 100%"), ["ohne Marke (RIVER genau)"]) self.assertEqual(B.marken("motor PREFLOP (6 im Topf, Klasse 25): fold 100%"), ["ohne Marke (PREFLOP)"]) self.assertEqual(B.marken(None), ["ohne Marke"]) class Abweichungen(unittest.TestCase): def test_nur_andere_zuege_mit_allen_feldern(self): q = {"street": "FLOP", "heroCards": ["Ah", "Kd"], "board": ["2c", "7d", "9s"], "pot": 0.1, "toCall": 0.05, "heroStack": 2.0} items = [{"hand": 1, "raum": "x 1893755", "zeit": "2026-12-03T10:00:00", "q": q}, {"hand": 2, "raum": "x", "q": q}, {"hand": 3, "raum": "x", "q": q}] a = [{"action": "FOLD", "reason": "NL2-Typ: weg"}, {"action": "CALL"}, None] b = [{"action": "CALL", "reason": "motor FLOP genau"}, {"action": "CALL"}, {"action": "CALL"}] aus = B.abweichungen(items, a, b, {"1": {"netto": -0.05, "bb": 0.02}}) self.assertEqual(len(aus), 1) x = aus[0] self.assertEqual((x["hand"], x["art"], x["marke_a"], x["ergebnis_hand"]["netto"], x["stapel"]), (1, "FLOP FOLD->CALL", ["NL2-Typ"], -0.05, 2.0)) z = B.zaehlung(aus) self.assertEqual((z["zahl"], z["je_art"], z["je_strasse"]), (1, {"FLOP FOLD->CALL": 1}, {"FLOP": 1})) self.assertEqual(list(B.nl2_je_regel(aus)), ["NL2-Typ"]) class Stapel(unittest.TestCase): def test_stapelentscheidung_und_tage_datei(self): q = {"street": "TURN", "heroSeat": 2, "heroStack": 1.0, "pot": 0.5, "toCall": 0.0, "history": []} self.assertTrue(B.stapel_entscheidung(q, {"action": "BET", "size": 0.5}, {"action": "CHECK"})) # Einsatz bindet 50 % des Rests self.assertFalse(B.stapel_entscheidung(q, {"action": "BET", "size": 0.2}, {"action": "CHECK"})) self.assertTrue(B.stapel_entscheidung(dict(q, toCall=0.45), {"action": "FOLD"}, {"action": "FOLD"})) # Call kostet 45 % des Rests import tempfile d = tempfile.mkdtemp() self.assertEqual(B.tage(d, "2026-12-03,2026-12-02,2026-12-01"), ["2026-12-03", "2026-12-02", "2026-12-01"]) open(os.path.join(d, "TAGE.txt"), "w").write("2026-12-03, 2026-12-02\n") self.assertEqual(B.tage(d, "2026-12-03,2026-12-02,2026-12-01"), ["2026-12-03", "2026-12-02"]) # TAGE.txt gilt vor --tage if __name__ == "__main__": unittest.main()