remove legacy systems

This commit is contained in:
SowinskiBraeden committed 2026-06-28 10:51:59 -07:00
1 parent 9e6f5bd3ef
commit 79c638b8fa
12 files changed
+191 -1188

No files matched your search

+29 -60
View File
@@ -1,15 +1,12 @@
from pathlib import Path
import tempfile
import unittest
import app as app_module
from charts import player_session_series
from services import (
build_leaderboard,
build_session_summaries,
pending_payout_carry_items,
prunable_empty_session_ids,
)
from storage import load_events, write_events
from utils import session_sort_key
@@ -189,7 +186,7 @@ class AccountingTests(unittest.TestCase):
self.assertEqual(entry.paid_out_cents, 0)
self.assertEqual(entry.payout_status, "settled")
def test_admin_can_apply_pending_payout_carry_in_to_open_session(self):
def test_pending_payout_carry_in_preserves_poker_investment(self):
rows = [
event("s1", "2026-01-01", "", "session_open", 0, 1),
event("s1", "2026-01-01", "A", "buyin", 10, 2),
@@ -200,37 +197,19 @@ class AccountingTests(unittest.TestCase):
event("s2", "2026-01-02", "A", "buyin", 10, 7),
]
with tempfile.TemporaryDirectory() as tmpdir:
data_path = Path(tmpdir) / "entries.csv"
write_events(data_path, rows)
original_path = app_module.app.config["DATA_PATH"]
app_module.app.config["DATA_PATH"] = data_path
sessions = build_session_summaries(rows)
self.assertEqual(
pending_payout_carry_items(sessions),
[{"player_name": "A", "amount_cents": cents(5)}],
)
try:
sessions = build_session_summaries(load_events(data_path))
self.assertEqual(
pending_payout_carry_items(sessions),
[{"player_name": "A", "amount_cents": cents(5)}],
)
with app_module.app.test_client() as client:
with client.session_transaction() as flask_session:
flask_session["is_admin"] = True
response = client.post(
"/admin/apply-payout-carry-in",
data={"session_id": "s2", "player_name": "A"},
)
finally:
app_module.app.config["DATA_PATH"] = original_path
self.assertEqual(response.status_code, 302)
updated_sessions = build_session_summaries(load_events(data_path))
target = next(s for s in updated_sessions if s.session_id == "s2")
target_entry = target.entries[0]
self.assertEqual(target_entry.payout_carry_in_cents, cents(5))
self.assertEqual(target_entry.invested_cents, cents(10))
self.assertEqual(target_entry.current_due_to_player_cents, cents(5))
rows.append(event("s2", "2026-01-02", "A", "payout_carry_in", 5, 8))
updated_sessions = build_session_summaries(rows)
target = next(s for s in updated_sessions if s.session_id == "s2")
target_entry = target.entries[0]
self.assertEqual(target_entry.payout_carry_in_cents, cents(5))
self.assertEqual(target_entry.invested_cents, cents(10))
self.assertEqual(target_entry.current_due_to_player_cents, cents(5))
def test_same_day_sessions_sort_by_session_sequence(self):
rows = [
@@ -248,7 +227,7 @@ class AccountingTests(unittest.TestCase):
["Mar 21, 2026 · S1", "Mar 21, 2026 · S2"],
)
def test_admin_prunes_only_empty_marker_sessions(self):
def test_prunable_empty_sessions_excludes_played_sessions(self):
rows = [
event("empty-1", "2026-01-01", "", "session_open", 0, 1),
event("empty-1", "2026-01-01", "", "session_close", 0, 2),
@@ -258,31 +237,21 @@ class AccountingTests(unittest.TestCase):
event("played-1", "2026-01-02", "", "session_close", 0, 6),
]
with tempfile.TemporaryDirectory() as tmpdir:
data_path = Path(tmpdir) / "entries.csv"
write_events(data_path, rows)
original_path = app_module.app.config["DATA_PATH"]
app_module.app.config["DATA_PATH"] = data_path
sessions = build_session_summaries(rows)
prunable_ids = prunable_empty_session_ids(rows, sessions)
self.assertEqual(prunable_ids, {"empty-1"})
try:
with app_module.app.test_client() as client:
with client.session_transaction() as flask_session:
flask_session["is_admin"] = True
response = client.post("/admin/prune-empty-sessions")
finally:
app_module.app.config["DATA_PATH"] = original_path
self.assertEqual(response.status_code, 302)
remaining = load_events(data_path)
self.assertEqual(
{row["session_id"] for row in remaining},
{"played-1"},
)
self.assertEqual(
[row["event_type"] for row in remaining],
["session_open", "buyin", "cashout", "session_close"],
)
remaining = [
row
for row in rows
if (row["session_id"].strip() or row["session_date"].strip())
not in prunable_ids
]
self.assertEqual({row["session_id"] for row in remaining}, {"played-1"})
self.assertEqual(
[row["event_type"] for row in remaining],
["session_open", "buyin", "cashout", "session_close"],
)
if __name__ == "__main__":
+11 -9
View File
@@ -1,10 +1,11 @@
import unittest
from stats import SessionEntry, SessionSummary, build_leaderboard
from models import SessionEntry, SessionSummary
from services import build_leaderboard
class CashInAccountingTest(unittest.TestCase):
def test_front_recovered_from_cashout_counts_as_session_cash_in(self):
def test_front_is_poker_investment_not_cash_in(self):
entry = SessionEntry(
session_id="2026-06-21-01",
session_date="2026-06-21",
@@ -20,10 +21,10 @@ class CashInAccountingTest(unittest.TestCase):
)
self.assertEqual(session.total_buy_in_cents, 2500)
self.assertEqual(session.total_front_collected_cents, 0)
self.assertEqual(session.total_cash_in_cents, 3000)
self.assertEqual(session.total_front_cents, 500)
self.assertEqual(session.total_cash_in_cents, 2500)
def test_collected_front_shortfall_counts_as_session_cash_in(self):
def test_debt_repayment_counts_as_session_cash_in(self):
entry = SessionEntry(
session_id="2026-06-21-01",
session_date="2026-06-21",
@@ -39,7 +40,7 @@ class CashInAccountingTest(unittest.TestCase):
)
self.assertEqual(session.total_front_collected_cents, 600)
self.assertEqual(session.total_cash_in_cents, 1000)
self.assertEqual(session.total_cash_in_cents, 600)
def test_written_off_front_does_not_count_as_session_cash_in(self):
entry = SessionEntry(
@@ -58,7 +59,7 @@ class CashInAccountingTest(unittest.TestCase):
self.assertEqual(session.total_front_writeoff_cents, 1000)
self.assertEqual(session.total_cash_in_cents, 0)
def test_leaderboard_cash_in_includes_collected_fronts(self):
def test_leaderboard_cash_in_uses_real_cash_only(self):
session = SessionSummary(
session_id="2026-06-21-01",
session_date="2026-06-21",
@@ -69,6 +70,7 @@ class CashInAccountingTest(unittest.TestCase):
player_name="Alex",
buy_in_cents=2500,
front_cents=500,
front_collected_cents=200,
cash_out_cents=4000,
)
],
@@ -77,8 +79,8 @@ class CashInAccountingTest(unittest.TestCase):
player = build_leaderboard([session])[0]
self.assertEqual(player.total_buy_in_cents, 2500)
self.assertEqual(player.total_front_collected_cents, 0)
self.assertEqual(player.total_cash_in_cents, 3000)
self.assertEqual(player.total_front_collected_cents, 200)
self.assertEqual(player.total_real_cash_in_cents, 2700)
if __name__ == "__main__":